花了一小时整了个错误示范
最近微词云不是很火么,然后网上找了个模板抄下来 看着像是python然后下了一个照着打
龟速打字打了一个多小时
run之后出现了一行美妙的字
"keyword argument repeated"
我悲愤地把那份失败的文件保存了
import wordcloud
from wordcloud import WordCloud,STOPWORDS
import matplotlib
from matplotlib import pyplot as plt
import numpy as np
from PIL import Image
import jieba
pythonworkInfo = open('phthonworkinfo.txt','r',encoding='utf-8',errors='ignore').read()
print(pythonworkInfo)
cutPythonInfo = jieba.cut(phthonworkInfo, cut_all=True)
myword = "".join (cutPythonInfo)
bgcolor = np.arrray(Image.open('peiqi.jpg'))
print(bgcolor)
mywordCloud = WordCloud(font_path='simkai.ttf',
width=400,height=200,
mask=bgcolor,
scale=1,
max_font_size=4,
stopwords=STOPWORDS,
random_state=30,
background_color='white',
max_font_size=200
).generate(myword)
plt.figimage(mywordCloud)
plt.imsave('python.png',mywordCloud)
如果有懂的能不能帮忙看看 太感谢了
毕竟不想让一个多小时的血汗白流......
6 条回复