From ec36b671ba9f83d9a37c03ec305a671b1e6910ac Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sun, 5 Jan 2025 09:45:43 +0800 Subject: [PATCH] save project --- diy3.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/diy3.py b/diy3.py index 5ae8e68..e1886f0 100644 --- a/diy3.py +++ b/diy3.py @@ -1,6 +1,13 @@ import wordcloud -with open('python二级考试大纲.txt',encoding='utf-8')as f: +from PIL import Image +import numpy +with open("python二级考试大纲.txt",encoding="utf-8")as f: text=f.read() -w=wordcloud.WordCloud(background_color="white",font_path="SinHei.ttf") +img=Image.open("bell.png") +data=numpy.array(img) +img_colors=wordcloud.ImageColorGenerator(data) +w=wordcloud.WordCloud(background_color="white", + font_path="SinHei.ttf", + mask=data,color_func=img_colors) w.generate(text) w.to_file("my_cloud.png") \ No newline at end of file -- libgit2 0.25.0