三国演义任务出现词频统计

使用jieba库将文本中的词汇进行提取,须要注意的是文本要存储为utf-8格式,不然会报错。 代码 import jieba txt = open("threekingdoms.txt","r", encoding="utf-8").read() words = jieba.lcut(txt) counts = {} for word in words: if len(word) ==
相关文章
相关标签/搜索