第三方库
jieba
wordcloud
import jieba
import wordcloud
f = open("D:\PycharmProjects\learn.txt","r",encoding="utf-8")#改成自己的文件路径
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud( font_path= 'msyhl.ttc', \
width=1000, height=700, background_color= 'white', \
) #字体 C盘windows\\fonts里边找
w.generate(txt)
w.to_file("grwordcloud.png")