Commit 360ab116 by BellCodeEditor

save project

parent 6b1fbc15
Showing with 20 additions and 2 deletions
ccccc.png

154 KB

import wordcloud import wordcloud
\ No newline at end of file from PIL import Image
import numpy
import jieba
with open("python二级考试大纲.txt",encoding="utf-8")as t:
text=t.read()
txt_list=jieba.lcut(text)
text=" ".join(txt_list)
img=Image.open("alice.png")
data=numpy.array(img)
img_color=wordcloud.ImageColorGenerator(data)
stop=["和","的","python","程序","基本"]
w=wordcloud.WordCloud(background_color='pink',font_path="Simhei.ttf",mask=data,color_func=img_color,stopwords=stop,max_font_size=60)
w.generate(text)
w.to_file('ccccc.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