【Python】WordCloud库的使用
建议挂梯子安装
栗子1:
import wordcloud txt="Life is stort,you need python" c=wordcloud.WordCloud(\ background_color="white") c.generate(txt) c.to_file("1.png")
栗子2:
import wordcloud import jieba txt="Python是一种跨平台的计算机程序设计语言。\ 是一个高层次的结合了解释性、编译性、互动性和面向对象的脚本语言。\ 最初被设计用于编写自动化脚本(shell),\ 随着版本的不断更新和语言新功能的添加,\ 越多被用于独立的、大型项目的开发。" c=wordcloud.WordCloud(width=1000,\ height=700,font_path="msyh.ttc") c.generate(" ".join(jieba.lcut(txt)))#对中文进行分词处理 c.to_file("1.png")
本文来自博客园,作者:木子欢儿,转载请注明原文链接:https://www.cnblogs.com/HGNET/p/12778664.html