Commit 612e8fea by BellCodeEditor

auto save

parent b0d19520
Showing with 12 additions and 3 deletions
import wordcloud
from PIL import Image
import numpy
import jieba
with open("python二级考试大纲.txt",encoding='utf-8') as f:
t=f.read()
w=wordcloud.WordCloud(background_color="white",font_path="SimHei.tff")
i=Image.open("bell.png")
tl=jieba.lcut(t)
text=" ",join(tl)
d=numpy.array(i)
ic=wordcloud.ImageColorGenerator(d)
st=["的","python","程序","和"]
w=wordcloud.WordCloud(background_color='white',font_path='SimHei.ttf',mask=data,color_func=ic,stopwords=st,max_font_size=60)
w.generate(t)
w.to_file("1.png")
\ No newline at end of file
w.to_file('1.png')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment