ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

词云

2021-07-31 11:31:23  阅读:97  来源: 互联网

标签:encoding color list 词云 import txt contour


# encoding:utf-8

import wordcloud
import jieba
import imageio

mk = imageio.imread("chinamap.jpg")

w = wordcloud.WordCloud(width=1000,
                        height=800,
                        background_color='white',
                        font_path='msyh.ttc',
                        mask=mk,
                        contour_width=0.1,
                        contour_color='steelblue'
                        )



with open('a.txt',encoding='GBK') as f:
    txt = f.read()

txt_list = jieba.lcut(txt)
strings = ''.join(txt_list)

w.generate(strings)

w.to_file('test.png')

 

 

标签:encoding,color,list,词云,import,txt,contour
来源: https://www.cnblogs.com/cforcnb/p/15083733.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有