Commit edc8fa6f by BellCodeEditor

save project

parent 6b1fbc15
1.jpg

98 KB

2.jpg

240 KB

3.jpg

273 KB

4.jpg

10.5 KB

import wordcloud
from PIL import Image
import numpy
import jieba
b=Image.open("4.jpg")
c=numpy.array(b)
d=wordcloud.ImageColorGenerator(c)
stopwords=["的","python","和","基本","程序"]
with open("python二级考试大纲.txt",encoding="utf-8") as f:
text=f.read()
e=jieba.lcut(text)
text=" ".join(e)
a=wordcloud.WordCloud(background_color="white",
font_path="SimHei.ttf",
mask=c,color_func=d,
stopwords=stopwords,max_font_size=60)
a.generate(text)
a.to_file("mycloud.png")
\ No newline at end of file
mycloud.png

47.8 KB

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