当前位置:   article > 正文

词云从文件中生成_词云生成方框

词云生成方框
from wordcloud import  WordCloud
import  jieba
with open(r'd:\\wh.txt','r')as file:
    word = file.read()
    words=jieba.lcut(word)
    newtxt="".join(words)

    wordcloud = WordCloud(font_path="C:\Windows\Fonts\simhei.ttf",
                          background_color="#FFFFFF",
                          height=700,
                          width=600,
                          repeat=True).generate(newtxt)
    wordcloud.to_file("c:\\wh002.png")
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/420761
推荐阅读
相关标签
  

闽ICP备14008679号