import re
with open('input.txt', 'r', encoding='utf-8') as file: text = file.read()
clean_text = re.sub(r'[^\u0600-\u06FF\s]+', '', text)
with open('output.txt', 'w', encoding='utf-8') as file: file.write(clean_text)
这样,你就可以从输入文本中删除所有非阿拉伯文本,并将清理后的文本保存到输出文件中。