You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
434 B
22 lines
434 B
2 months ago
|
# 导入结巴分词模块
|
||
|
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')
|