f = open("1.txt", "r", encoding="utf-8")
f_new = open("2.txt", "w", encoding="utf-8")
find_str = "wangzai"
replace_str = "doubi"
for line in f:
    if find_str in line:
        line = line.replace(find_str, replace_str)
    f_new = write(line)
f.close()
f_new.close()
os.remove("config.txt")
os.rename("config1.txt", "config.txt")

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2021-10-23
  • 2022-12-23
  • 2021-04-22
相关资源
相似解决方案