python词云图《三国演义》
import jieba
import wordcloud
file = open(“三国演义.txt”, “r”, encoding=“utf-8”)
t = file.read()
file.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(
width=1000, height=700,
background_color=“white”,
font_path=“msyh.ttc”
)
w.generate(txt
原创
2021-10-29 11:07:55 ·
1085 阅读 ·
0 评论