import os import re from collections import Counter import pandas as pd #提取txt文件里面的弹幕,并存于列表中 def read_danmu_files(directory): danmu_data = [] for filename in os.listdir(directory): if filename.endswith('paris_olympics_danmak.txt'): with open(os.path.join(directory, filename), 'r', encoding='utf-8') as file: danmu_data.extend(file.readlines()) return danmu_data def count_danmu(): danmu_data = read_danmu_files('./') # 当前目录下 #用正则表达式提取含有ai的弹幕 ai_danmaku = [danmaku for danmaku in danmu_data if re.search(r'(?