f=open('yesterday','r',encoding='utf-8') f_new=open('yesterday.bak','w',encoding='utf-8') for line in f: if '当我小的时候' in line: line=line.replace('当我小的时候','当zhow小的时候') f_new.write(line) f.close() f_new.close()
本文共 274 字,大约阅读时间需要 1 分钟。
f=open('yesterday','r',encoding='utf-8') f_new=open('yesterday.bak','w',encoding='utf-8') for line in f: if '当我小的时候' in line: line=line.replace('当我小的时候','当zhow小的时候') f_new.write(line) f.close() f_new.close()
转载于:https://www.cnblogs.com/zhowhen/p/8972899.html