Commit 52296d04 by BellCodeEditor

auto save

parent 8a73127c
Showing with 14 additions and 14 deletions
......@@ -2,17 +2,17 @@ import wordcloud
from PIL import Image
import numpy
import jieba
with open('python二级考试大纲.txt','r',encoding="utf-8") as f:
text=f.read()
img=Image.open("bell.png")
stop=["的"]
data=numpy.array(img)
img_color=wordcloud.ImageColorGenerator(data)
w=wordcloud.WordCloud(background_color="white",font_path="SimHei.ttf",mask=data,color_func=img_color,stopwords=stop,max_font_size=60)
# with open('python二级考试大纲.txt','r',encoding="utf-8") as f:
# text=f.read()
# img=Image.open("bell.png")
# stop=["的"]
# data=numpy.array(img)
# img_color=wordcloud.ImageColorGenerator(data)
# w=wordcloud.WordCloud(background_color="white",font_path="SimHei.ttf",mask=data,color_func=img_color,stopwords=stop,max_font_size=60)
text='你站在桥上看风景,看风景人在楼上看你。明月装饰了你的窗子,你装饰了别人的梦'
a=jieba.lcut(text,cut_all=False)
text=" ".join(a)
print(text)
jieba.lcut(text)
text="".join(text)
w.generate(text)
w.to_file("词云.png")
\ No newline at end of file
# w.generate(text)
# w.to_file("词云.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