from wordcloud import WordCloud
f = open(u'testfile.txt', 'r').read()
wordcloud = WordCloud(background_color="white", width=1000, height=860, margin=2).generate(f)
import matplotlib.pyplot as plt
plt.imshow(wordcloud)
plt.axis("off")
plt.show()
wordcloud.to_file('test1.png') # 保存图片
一个简单的wordcloud
最新推荐文章于 2024-06-04 06:56:40 发布