Python3 词云错误:OSError: cannot open resource解决办法

匿名 (未验证) 提交于 2019-12-02 22:51:30

Wordcloud设置参数font_path = “” Mac 系统中使用:
font_path="Hiragino Sans GB.ttc"

代码效果:

from wordcloud import WordCloud import matplotlib.pyplot as plt   import  jieba                    path_txt = 'word.txt' # 随便一个新闻 file = open(path_txt,'r',encoding='UTF-8').read() cut_text = " ".join(jieba.cut(file))  wordcloud = WordCloud(    font_path="Hiragino Sans GB.ttc",    # 背景,宽高    background_color="white",    width=1000,    height=880).generate(cut_text)plt.imshow(wordcloud, interpolation="bilinear") plt.axis("off") plt.show()  

文章来源: https://blog.csdn.net/qq_39248703/article/details/92427621
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!