import jieba
txt = open("三国演义.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
items = list(counts.items())
items.sort(key=lambda x:x[1], reverse=True)
for i in range(15):
word, count = items[i]
print ("{0:<10}{1:>5}".format(word, count))
最后
以上就是着急小蝴蝶最近收集整理的关于用python对《三国演义》的人物出场进行统计的全部内容,更多相关用python对《三国演义》内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复