#!/usr/bin/env python # -*- coding: UTF-8 -*- def alter(file,old_str,new_str): file_data = "" with open(file, "r", ) as f: for line in f: if old_str in line: line = line.replace(old_str,new_str) file_data += line with open(file,"w",) as f: f.write(file_data) alter("@[email protected]", "@[email protected]", "@[email protected]")
原文地址:https://www.cnblogs.com/niwajiang1/p/9419048.html
时间: 2024-10-07 05:15:40