python script:
import re
def replace_aaa_with_bbb(input_file,output_file):
#read file content
with open(input_file,'r') as file:
content = file.read()
modified_content = re.sub(r'aaa','bbb',content)
#write the modified file to new file
with open(output_file,'w') as file:
file.write(modified_content)
if __name__ == "__main__":
input_file_path = "./replace_source_file.txt" #原始文件名
output_file_path = "./replace_destination_file.txt" #输出文件名
replace_aaa_with_bbb(input_file_path,output_file_path)
print("replace done")
注意:需要修改的地方包括:#原始文件名、#输出文件名、aaa、bbb,即可直接使用。