Commit 4a5b46a3 by BellCodeEditor

save project

parent fa601d68
import wordcloud
from PIL import Image
import numpy
import jieba
with open('python二级考试大纲.txt',encoding='utf-8') as f:
text=f.read()
text_list=jieba.lcut(text)
text="".join(text_list)
img=Image.open("bell.png")
data=numpy.array(img)
img_colors=wordcloud.ImageColorGenerator(data)
stopwords=["的","python","基本","和","程序"]
w=wordcloud.WordCloud(background_color='white',font_path="SimHei.ttf",mask=data,color_func=img_colors,stopwords=stopwords,max_font_size=60)
w=wordcloud.WordCloud(background_color='white',font_path="Simhei.ttf")
w.generate(text)
w.to_file("mycloud.png")
w.to_file('mycloud.png')
......@@ -5,4 +5,6 @@ data = [["姓名", "语文", "数学", "英语"],
["聪聪", 95, 91,95]]
with open("scores.csv","w",encoding="UTF-8",newline='')as csvfile:
writer=csv.writer(csvfile)
writer.writerows(data)
\ No newline at end of file
writer.writerows(data)
import wordcloud
from PIL import Image

223 KB | W: | H:

75.8 KB | W: | H:

mycloud.png
mycloud.png
mycloud.png
mycloud.png
  • 2-up
  • Swipe
  • Onion skin
import wordcloud
with open('python二级考试大纲.txt',encoding='utf-8') as f:
text=f.read()
w=wordcloud.Wordcloud(background_color='white',font_path="SimHei.ttf")
w.generate(text)
w.to_file("mycloud.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