Commit 36d5667c by BellCodeEditor

auto save

parent 6b1fbc15
Showing with 22 additions and 2 deletions
import wordcloud import wordcloud
\ No newline at end of file from PIL import Image
import numpy
import jieba
with open('python二级考试大纲.txt','r',encoding='utf-8') as f:
text=f.read()
text_list = jieba.lcut(text) #精确分词为列表
text = ' '.join(text_list) #把列表转成字符串
feici = ['python','基本','的','和','程序','类型','库','考试','开发']
tu = Image.open('bell.png')
v=numpy.array(tu)
tuc = wordcloud.ImageColorGenerator(v)
w=wordcloud.WordCloud(background_color='white',font_path='SimHei.ttf',mask = v,color_func=tuc,stopwords=feici,max_font_size=66)
w.generate(text)
w.to_file('my_cloud.png')
\ No newline at end of file
import jieba
text = '陈今天穿了两件衣服'
text1 = jieba.lcut(text)
print(text1)
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