词云
from wordcloud import WordCloud, STOPWORDS
from matplotlib import pyplot as plt
fig,ax=plt.subplots()
with open(r'...\vanity 张钰贤.txt') as f:
text=f.read()
mycloudword=WordCloud(width=800,
height=600,
scale=1,
margin=2,
background_color='white',
max_words=200,
min_font_size=40,
max_font_size=140,
stopwords=STOPWORDS,
random_state=50).generate(text)
ax.imshow(mycloudword)
ax.axis("off")
plt.show()
mycloudword.to_file(r"...\vanity张钰贤.png")


浙公网安备 33010602011771号