词云的生成

词云的生成

import wordcloud
import imageio
mask = imageio.imread(r"D:\python\7.17\test7.png") ##导入图片
f = open(r'D:\python\z', 'r', encoding='utf8') ##打开文档
data = f.read()
w = wordcloud.WordCloud(font_path=r'C:\Windows\Fonts\微软雅黑\msyhbd', mask=mask, width=1000, height=700,
background_color="white") ##选择字体
w.generate(data)
w.to_file('outfile.png') ##输出png

posted @ 2019-07-19 15:08  oxtime  阅读(428)  评论(0编辑  收藏  举报