Commit 17541e89 by BellCodeEditor

save project

parent e14a2ebd
Showing with 6 additions and 4 deletions
...@@ -2,11 +2,12 @@ import wordcloud ...@@ -2,11 +2,12 @@ import wordcloud
from PIL import Image from PIL import Image
import numpy import numpy
img = Image.open('bell.png')
data = numpy.array(img)
w = wordcloud.WordCloud(background_color='white', font_path='SimHei.ttf',mask=data)
with open('python二级考试大纲.txt','r',encoding="utf-8") as f: with open('python二级考试大纲.txt','r',encoding="utf-8") as f:
t1 = f.read() t1 = f.read()
img=Image.open('bell.png')
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)
w.generate(t1) w.generate(t1)
w.to_file('C:\\Users\\Administrator\\Desktop\\词云.png') w.to_file('C:\\Users\\Administrator\\Desktop\\词云.png')
\ No newline at end of file

212 KB | W: | H:

79.5 KB | W: | H:

词云.png
词云.png
词云.png
词云.png
  • 2-up
  • Swipe
  • Onion skin
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