下面是例子是读取一个文件内容,并且改变其中满足正则的行,进行内容追加。 # use command : reWriteFile.py oldFileName.txt newFileName.txt import re import sys param = sys.argv if len(param) > 3: sys.exit() oldFile = param[1] newFile = open(param[2], "w+") with open(oFile) as f2: while True: line = f2.readline() # read con