ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` import wordcloud w = wordcloud.WordCloud(width=600,height=400,background_color='white') w.generate("Python and WordCloud and generate and file") w.to_file("pywordcloud.png") ``` ``` import wordcloud w = wordcloud.WordCloud(width=600,height=400,background_color='white',font_path='msyhbd.ttc') w.generate("小学生 是 小学生 我 是 小学生") w.to_file("pywordcloud.png") ``` ``` import wordcloud import jieba w = wordcloud.WordCloud(width=600,height=400,background_color='white',font_path='msyhbd.ttc') file = open('c:\\503\\三国演义.txt') txt = file.read() lst = jieba.lcut(txt) lst1 = ''.join(lst) print(type(lst1)) w.generate(lst1) w.to_file("pywordcloud.png") ``` ``` list1 = ['a','b'] print(type(list1)) liststr = ' '.join(list1) print(type(liststr)) #TypeError: expected string or bytes-like object ```