文件内容替换

# fileName 文件名

# oldStr 源字符串

# newStr 新字符串

def fileContentAlter(fileName, oldStr, newStr):
  file_data = ""
  with open(fileName, "r", encoding="utf-8") as f:
  for line in f:
    line = line.replace(oldStr, newStr)
    file_data += line
  with open(fileName, "w", encoding="utf-8") as f:
    f.write(file_data)

相关文章:

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