Commit 0339bf5f by BellCodeEditor

save project

parent 691bf968
Showing with 2 additions and 20 deletions

211 KB | W: | H:

191 KB | W: | H:

cloud.png
cloud.png
cloud.png
cloud.png
  • 2-up
  • Swipe
  • Onion skin
import wordcloud
from PIL import Image
import numpy
import jieba
with open("python二级考试大纲.txt",'r',encoding='utf-8') as word:
text = word.read()
text_list = jieba.lcut(text)
sentence = " ".join(text_list)
stop = ["必选","基本的","定义","的","间","不","分","和","基本"]
image = Image.open('bell.png')
data = numpy.array(image)
img_colors = wordcloud.ImageColorGenerator(data)
w = wordcloud.WordCloud(background_color='white',
font_path='SimHei.ttf',
mask=data,color_func=img_colors
,stopwords=stop,max_font_size=60)
w.generate(sentence)
w.to_file("cloud.png")
\ No newline at end of file
import wordcloud
\ 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