2021
03-09
03-09
Python jieba 中文分词与词频统计的操作
我就废话不多说了,大家还是直接看代码吧~#!python3#-*-coding:utf-8-*-importos,codecsimportjiebafromcollectionsimportCounterdefget_words(txt):seg_list=jieba.cut(txt)c=Counter()forxinseg_list:iflen(x)>1andx!='\r\n':c[x]+=1print('常用词频度统计结果')for(k,v)inc.most_common(100):print('%s%s%s%d'%(''*(5-len(k)),k,'*'*int(v/3),v))if__name__=='__main__'...
继续阅读 >