import wordcloud
file = open(r"D:\PyCharm实例\抓数据\最多收藏.txt",encoding="utf-8")
text = file.read()
wc = wordcloud.WordCloud()
wc.generate(text)
image = wc.to_image()
#stopwords = {" "}
#wc = wordcloud.WordCloud(font_path=r"D:\PyCharm实例\抓数据\STSONG.TTF",stopwords=stopwords)
wc = wordcloud.WordCloud(font_path=r"D:\PyCharm实例\抓数据\STSONG.TTF")
wc.generate(text)
image = wc.to_image()
image.show()
来源:CSDN
作者:CoCo 13
链接:https://blog.csdn.net/weixin_43206161/article/details/104201802