#KochDrawV2.py
import jieba
txt = open("C:\\Users\\94079\\Desktop\\test.txt","r",encoding="utf-8").read()
words = jieba.lcut(txt)
counts = {}
for word in words:
if len(word) == 1:
continue
counts[word] = counts.get(word,0)+1
items = list(counts.items())
items.sort(key = lambda x:x[1],reverse = True)
print(items)
for i in range(200):
word,count = items[i]
print("NO.{}: W:{} T:{} ".format(i+1,word,count))
【python】词频统计
猜你喜欢
转载自blog.csdn.net/qq_41514794/article/details/89446086
今日推荐
周排行