Python云图——WordCloud了解一下
字符可以作画(参考前文:使用记事本画出照片) 字符串一样也可以 安装词云WordCloud. 1 pip install wordcloud 编写要生成词云的内容字符串 保存为txt格式就可以了 使用Python代码实现词云 1 from wordcloud import WordCloud 2 import matplotlib.pyplot as plt 3 4 5 if __name__ == '__main__': 6 f = open(u'data.txt','r').read() 7 word = WordCloud(background_color='white',width=1000,height=860,margin=2).generate(f) 8 plt.imshow(word) 9 plt.axis('off') 10 plt.show() 11 word.to_file('test.png') 效果图: 当然这里只是简单的使用了WordCloud的词云功能 他的功能远远不止于此