标签:else coding highlight span lis pre list 9.png ima
import jieba fo=open(‘shuihuzhuan.txt‘,‘r‘,encoding=‘utf-8‘) str=fo.read() fo.close() words=list(jieba.cut(str)) dt={} for i in words: if len(i)==1: continue else: dt[i]=dt.get(i,0)+1 item=list(dt.items()) item.sort(key=lambda x:x[1],reverse=True) for i in range(20): print(item[i])
运行截图
标签:else coding highlight span lis pre list 9.png ima
原文地址:http://www.cnblogs.com/Betty18/p/7612370.html