def draw_wordcloud(file_name):
with codecs.open(file_name,encoding='utf-8') as f:
comment_text=f.read()
color_mask=imread('template.png') #??????
stopwords = ['png','douban','com','href','https','img','img3','class','source','icon','shire',u'??',u'??',u'??',u'??',u'??',u'??', u'??', u'??', u'??', u'??', u'??', u'??', u'??', u'??', u'??', u'??', u'??', u'??', u'??',
u'??', u'??', u'??', u'??']
font = r'C:\Windows\Fonts\simfang.ttf'
cloud=WordCloud(font_path=font,background_color='white',max_words=20000,max_font_size=200,min_font_size=4,mask=color_mask,stopwords=stopwords)
word_cloud=cloud.generate(comment_text) #????
word_cloud.to_file('pjl_cloud.jpg')
评论列表
文章目录