Python——wordcloud
import jieba
from wordcloud import WordCloud,STOPWORDS
import matplotlib.pyplot as plt
from scipy.misc import imread
back_ground = imread('F:/Python/PythonLeaning/测试专用文件夹/01300000165488121825589267854.png')
s1 = 'Time is short life; But even if the target clock speed along with life, ' \
'to one hour We end to this period of time was also engaged to spend too long. '
s2 = 'A prodigal son go with the sun is the general,' \
' but he was not the same as the solar cycle.'
mylist = [s1,s2]
word_list = [" ".join(jieba.cut(sentence)) for sentence in mylist]
new_text = ' '.join(word_list)
wordcloud = WordCloud(font_path='F:/Comic_Font.ttf',
background_color="white",
mask=back_ground,
).generate(new_text)
plt.imshow(wordcloud)
plt.axis("off")
plt.show()
wordcloud.to_file('test.png')
Win a contest, win a challenge
posted on 2018-03-17 16:18 pandaboy1123 阅读(157) 评论(0) 收藏 举报
浙公网安备 33010602011771号