def cal(sentence,word): sentence = sentence.lower() # 统一小写(空格和数字在str.lower()作用下不变) word = word.lower() #统一小写 words = [ a for a in sentence if a == word ] # list comprehension 构造sentence中与word一致的列 frequency = len(words) # 列长度即为sentence中包含word的长度 return frequency in_1 = input() # 变量1 in_2 = input() # 变量2 out_ = cal(in_1,in_2) # 所求 print(out_) # print出所求