💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
``` import jieba file = open('c:\\503\\三国演义.txt') txt = file.read() #txt1 = "小学生 是 小学生 我 是 小学生" lst1 = jieba.lcut(txt) #lst1 = jieba.lcut(txt1) print(len(lst1)) #print(len(lst)) counts = {} for word in lst1: #print(len(word)) if len(word) == 1: continue else: #print(word) #counts[word] = counts.get(word,0) counts[word] = counts.get(word,0) + 1 #print(counts) print(max(counts.values())) for k in counts: if counts[k] >500: print(k,counts[k]) ``` ``` dict1 = {'Name': 'Runoob', 'Age': 27} print(dict1.get('Age',0)) lst2 = ['我','我','我'] lst1 = ['我', '是', '小学生', '我', '是', '小学生'] for word in lst1: print(word) dict1[word]=dict1.get(word,0)+1 print(dict1) print(dict1.keys()) print(dict1.items()) for k,v in dict1.items(): print(k,v) for k in dict1: print(k,dict1[k]) for k,v in dict1.items(): print(k,v) for k in dict1.keys(): print(k,dict1[k]) for (k,v) in dict1.items(): print(k,v) ```