Commit 410a9df1 by BellCodeEditor

auto save

parent ac70f2c8
Showing with 26 additions and 20 deletions
import wordcloud
import numpy
# import wordcloud
# import numpy
# from PIL import Image
# import jieba
# with open("python二级考试大纲.txt","r",encoding="utf-8") as file:
# p = file.read()
# j_text = jieba.lcut(p)
# p = " ".join(j_text)
# img = Image.open("bell.png")
# data = numpy.array(img)
# stopwords = ["python","的","和"]
# img_colors = wordcloud.ImageColorGenerator(data)
# w = wordcloud.WordCloud(background_color="white",
# font_path="SimHei.ttf",
# mask=data,
# color_func=img_colors,
# max_font_size=60,
# stopwords=stopwords)
# w.generate(p)
# w.to_file("mycloud.png")
from tkinter import filedialog,Tk
from PIL import Image
import jieba
with open("python二级考试大纲.txt","r",encoding="utf-8") as file:
p = file.read()
j_text = jieba.lcut(p)
p = " ".join(j_text)
img = Image.open("bell.png")
data = numpy.array(img)
stopwords = ["python","的","和"]
img_colors = wordcloud.ImageColorGenerator(data)
w = wordcloud.WordCloud(background_color="white",
font_path="SimHei.ttf",
mask=data,
color_func=img_colors,
max_font_size=60,
stopwords=stopwords)
w.generate(p)
w.to_file("mycloud.png")
\ No newline at end of file
root = Tk()
root.withdraw()
path = filedialog.askopenfilenames(title ='选择图片文件',filetypes=[('All Files','*')],initialdir = "./")
print(path)
\ 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