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')