我需要从下面的对话中提取人名、时间戳和对话内容。
在影刀的python模块中代码如下:
def extract(chat_log):
name_list = []
timestamp_list = []
message_list = []
pattern = re.compile(r'([^\s]+)\s+(\d{4}/\d{1,2}/\d{1,2}\s+\d{2}:\d{2}:\d{2})\n((?:.+\n?)+)', re.MULTILINE)
matches = pattern.findall(chat_log)
for match in matches:
name, timestamp, message = match
name_list.append(name)
timestamp_list.append(timestamp)
message_list.append(message)
return [name_list, timestamp_list, message_list]
上面的代码在vscode python3.7环境下正常运行,但是在影刀中就无法提取,返回的是空列表。这是什么原因呢?
Mike 2024/7/3 22:16:10
段落1
段落2
段落3
Jay 2024/7/3 22:16:29
666
老铁 2024/7/3 22:16:38
给力啊!
旺财 2024/7/3 22:17:26
是啊