diff --git a/findai.py b/findai.py new file mode 100644 index 0000000..e71f4bd --- /dev/null +++ b/findai.py @@ -0,0 +1,14 @@ +data_list = [] # 存放AI弹幕列表 +f = open('全弹幕.txt',encoding='utf-8') +keywords = ['AI','Ai','ai','智能','人工智能','网络','自动','全息','投影','8k','8K'] # 关键词 +for index in f: + if any(i in index for i in keywords)==True: # 对每个弹幕进行判断,是否至少包含一个关键词 + print(index) + data_list.append(index) # 写入AI弹幕列表 +print(data_list) #打印出来更加直观 +for index in data_list: + with open('AI弹幕.txt',mode='a',encoding='utf-8') as f: + f.write(index) # 写入AI弹幕.txt文本 +for index in data_list: + with open('AI弹幕.xls',mode='a',encoding='utf-8') as f: + f.write(index) # 写入AI弹幕.xls文本