词云作业

代码

from wordcloud import WordCloud

import matplotlib.pyplot as plt

 

f = open('../txt/wordcloud.txt', 'r').read()

wordcloud = WordCloud(background_color="white",width=1000,height=860,margin=2).generate(f)

plt.imshow(wordcloud)

plt.axis("off")

plt.show()

wordcloud.to_file('../picture/example1.png')

 

posted @ 2021-04-22 19:45  缥缃璀错  阅读(45)  评论(0)    收藏  举报