import jieba txt=open("loe.txt",'r',encoding='utf-8').read() news=list(jieba.cut(txt)) exp={','} keys=set(news)-exp dic={} for w in keys: if len(w)>1: dic[w]=news.count(w) word=list(dic.items()) word.sort(key=lambda x:x[1],reverse=True) for i in range(20): print(word[i])
转载于:https://www.cnblogs.com/loe0506/p/7610373.html