import os
defchange(file_path,old_word):withopen(file_path,'r',encoding='utf-8')as read_f,open('new_file.txt','w',encoding="utf-8")as write_f:
res = read_f.read()
write_f.write(res.replace(old_word,'go go go'))
os.remove(file_path)
os.rename('new_file.txt',file_path)
change('db.txt','头破血流')