Commit 4afaf995 by BellCodeEditor

auto save

parent 6b1fbc15
abc.jpeg

83.5 KB

for i in range(850000,100
\ No newline at end of file
import wordcloud
\ No newline at end of file
import wordcloud as wc
from PIL import Image
import numpy
import time
import jieba
start_time=time.time()
print('起始时间:'+str(start_time))
with open('python二级考试大纲.txt',encoding='utf-8') as f:
text = f.read()
txt_list=jieba.lcut(text)
text=' '.join(txt_list)
stopwords=['的','基本的','基本','掌握','python','和','并','程序']
img=Image.open('omega_flowey.jpeg')
data=numpy.array(img)
img_colors=wc.ImageColorGenerator(data)
w=wc.WordCloud(background_color='white',font_path='SimHei.ttf',
mask=data,color_func=img_colors,
stopwords=stopwords,max_font_size=100)
w.generate(text)
w.to_file(r'C:\Users\Administrator\Desktop\__cloud__.png')
end_time=time.time()
print('结束时间'+str(end_time))
use_time=end_time-start_time
print('共用时:'+str(use_time)+'秒')
#影响因素:图片大小
\ 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