环境
python2.7、anaconda2、依赖wordcloud
环境安装就不讲了,自己下吧,就是考验网速。
步骤
方法1:使用jupyter的notebook做:网址一篇英文词云,一篇中文词云。
方法2:使用pycharm做,因为我在notebook上一直报找不到wordcloud 这个module,但我本地确实装了wordcloud,所以使用pycharm做。
上代码
word_en
from wordcloud import WordCloud
import matplotlib.pyplot as plt
filename = "D:\Projects\demo\yes-minister.txt"
with open(filename) as f:
mytext = f.read()
wordcloud = WordCloud().generate(mytext)
plt.imshow(wordcloud, interpolation=