三國演義任務出現詞頻統計

使用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) ==
相關文章
相關標籤/搜索