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.

23 lines
645 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import wordcloud
import jieba
from matplotlib import pyplot as plt
from wordcloud import WordCloud, ImageColorGenerator
from PIL import Image
import numpy as np
#爬不到很多关于ai的数据用所有数据完成数据可视化
f= open('D:\danmucrawler\danmupapa\danmu.txt',encoding='utf-8')
text=f.read().encode('utf-8').decode('utf-8')
print(text)
llist=jieba.lcut(text)
string=''.join(llist)
wc=wordcloud.WordCloud(
width=1000, height=500, background_color='white', font_path='msyh', scale=15
)
wc.generate(string)
wc.to_file('ciyun1.png')
plt.imshow(wc, interpolation='bilinear')
plt.axis("off")
plt.show()