import jieba
from wordcloud import WordCloud
fo=open("D:/Python/作业9(2021.4.12)/白鹿原.txt",\
        "r+",encoding="utf-8")
ls=jieba.lcut(fo.read())
lc="".join(ls)
wordcloud=WordCloud (background_color="white",\
                    width=800,\
                    height=600,\
                    font_path="msyh.ttc",\
                    max_words=200,\
                    max_font_size=80,\
                    ).generate(lc)
wordcloud.to_file("白鹿原词云1.png")

posted on 2021-04-18 13:54  trf0001  阅读(96)  评论(0)    收藏  举报