#政府工作报告词云展示
import jieba
import wordclouddelwords = {"各位代表","表示诚挚感谢","我代表国务院","左右","现在","向大会报告政府工作"}
f = open("2020年政府工作报告全文.txt","r",encoding = "utf - 8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = "".join(ls)
w = wordcloud.WordCloud(font_path = ",width = 1000,height = 700 ,background_color = "white",stopwords = delwords , max_words = 50)
w.generate(txt)
w.to_file("2020年政府工作报告词云.png")#一个学生物的编程爱好者
下面放上图片效果。
这个程序我在编写的时候的主要问题在wordcloud库里面的函数排列上,注意函数顺序的排列是很重要的。
#2020年政府工作报告原文网页:.shtml
本文发布于:2024-02-02 10:27:05,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170684082443191.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |