文件内容替换
# 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)