标签:new int count sort code item coding .so news
中文分词
import jieba news=open(‘jane.txt‘,‘r‘,encoding=‘utf-8‘).read() words=list(jieba.cut(news)) exp={‘是不是‘,‘只不过‘} keys=set(words)-exp dic={} for w in keys: if len(w)>2: dic[w]=words.count(w) wc=list(dic.items()) wc.sort(key=lambda x:x[1],reverse=True) for i in range(20): print(wc[i])
标签:new int count sort code item coding .so news
原文地址:http://www.cnblogs.com/zsy-97/p/7610383.html