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.

20 lines
750 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 requests
from bs4 import BeautifulSoup
import re
import time
import jieba
import wordcloud
import matplotlib.pyplot as plt
import pandas as pd
from pandas import ExcelWriter
from collections import Counter
def chuli(etxt):
#danmustr=''.join(i for i in etxt) #将所有弹幕拼接在一起
#words=list(jieba.cut(danmustr)) ###利用jieba库将弹幕按词进行切分
words=[i for i in etxt if len(i)>1] ###挑出长度大于1的词语为去除诸如啊等字符
wc=wordcloud.WordCloud(background_color='white',height=1000,width=1000,font_path='simsun.ttc')#利用wordcloud库定义词云图片的信息
wc.generate(' '.join(words)) ##生成图片
print(wc)
plt.imshow(wc)
plt.show()