中文词频统计
import jieba a=open('C:/1.txt','r',encoding='utf-8').read() for i in '\n,.\()。,123"?': a=a.replace(i,' ') b=jieba.cut(a) d=list(b) exc={' ','和','你','使','都','所','又','一个','啊', '也是', '的','了','(','…','阿','廖沙','也','是','对','就','“','”','地','他','她'} dict={} key=set(d) key=key-exc print(key) for i in key: dict[i]=d.count(i) st=list(dict.items()) st.sort(key=lambda x:x[1],reverse=True) print(st) for i in range(20): print(st[i])