改写代码: import os import re folder_path = "lab3" file_names = os.listdir(folder_path) answer = "" for file_name in file_names: file_path = os.path.join(folder_path, file_name) with open(file_path, "r") as file: content = file.read() pattern = answer + ".*?(.)(?!" + answer + ").*" diff_chars = re.findall(pattern, content) for char in diff_chars: answer += char print(answer)
时间: 2024-04-10 21:28:48 浏览: 129
File_Folder_to_XML11.zip_File Fold_The Pause
import os
import re
folder_path = "lab3"
file_names = os.listdir(folder_path)
answer = ""
for file_name in file_names:
file_path = os.path.join(folder_path, file_name)
with open(file_path, "r") as file:
content = file.read()
pattern = answer + ".*?(.)(?!" + answer + ").*"
diff_chars = re.findall(pattern, content)
for char in diff_chars:
answer += char
print(answer)
阅读全文