标签:sort int 合并 class set lam list reverse logs
中文分词
import jieba txt=open(‘111.txt‘,‘r‘,encoding=‘utf-8‘).read() words=list(jieba.cut(txt)) keys=set(words) dic={} for w in keys: if len(w)>1: dic[w]=words.count(w) wc=list(dic.items()) wc.sort(key=lambda x:x[1],reverse=True) for i in range(10): print(wc[i])
标签:sort int 合并 class set lam list reverse logs
原文地址:http://www.cnblogs.com/wujialing/p/7610459.html