import jieba
txt=open("C:\\Users\\11765\Desktop\\新建 文本文档.txt", "r", encoding='utf-8').read()
words=jieba.lcut(txt)
counts={}
for word in words:
if len(word) ==1:
continue
else:
counts[word]=counts.get(word,0)+1
it=list(counts.items())
it.sort(key=lambda x:x[1],reverse=True)
for i in range(20):
word, count =it[i]
print("{0:<10}{1:>5}".format(word, count))
09-23
522
03-19
4万+
02-01
2159
06-29