# 安装jieba,wordcloud,matplotlib,pillow
#复制字体并改名
#运行文件输出
import jieba
from wordcloud import WordCloud
txt = '弱小的人,才习惯,嘲讽和否定,而内心,强大的人,从不吝啬赞美和鼓励!我们就是后浪,奔涌吧!后浪,奔涌吧!'
with open(r'./新闻稿.txt','r',encoding='utf-8') as f:
filecontent=f.read()
# print(sss)
words = jieba.lcut(filecontent) #精确分词
newtxt = ''.join(words) #空格拼接
wordcloud = WordCloud(font_path = r"./msyh.ttf").generate(newtxt)
wordcloud.to_file('中文词云图.jpg')
自己动手做词云
最新推荐文章于 2024-11-06 09:59:52 发布