源代码
import jieba
import wordcloud
fc=open('紫川.txt','r',encoding='utf-8')
q=fc.read()
fc.close()
words=jieba.lcut(q)
txt=' '.join(words)
w=wordcloud.WordCloud(width=800,height=800,
font_path='msyh.ttc',max_words=200,
background_color='white')
w.generate(txt)
w.to_file('紫川词.png')
运行结果