From d9a8e2ca2cd9734e98f35c64aa61f8c0bf6c5744 Mon Sep 17 00:00:00 2001 From: pff5ls68k <1822218970@qq.com> Date: Fri, 13 Sep 2024 15:01:20 +0800 Subject: [PATCH] ADD file via upload --- 词云.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 词云.py diff --git a/词云.py b/词云.py new file mode 100644 index 0000000..0005aa6 --- /dev/null +++ b/词云.py @@ -0,0 +1,21 @@ +# 导入结巴分词模块 +import jieba +# 导入词云图 +import wordcloud + +# 读取文件内容 +f = open('弹幕.txt', encoding='utf-8') +txt = f.read() +print(txt) +string = ''.join(jieba.lcut(txt)) +print(string) +wc = wordcloud.WordCloud( + width=1000, + height=1000, + background_color='white', + # 指定文字 + font_path='msyh.ttc', + scale=15, +) +wc.generate(string) +wc.to_file('弹幕词云.png')