标签:pre replace utf8 pen line 打开 new with div
f = open(‘cc‘,‘r‘,encoding=‘utf-8‘) f_new = open(‘cc.bak‘,‘w‘,encoding=‘utf8‘) for line in f: if ‘ 想让我知难而退‘ in line: line = line.replace(‘想让我知难而退‘,‘想让我主动出击‘) f_new.write(line) f.close() f_new.close() with open(‘cc‘,‘r‘,encoding=‘utf-8‘) as f , open(‘cc2‘,‘r‘,encoding=‘utf-8‘) as f2: #同时打开多个文件
标签:pre replace utf8 pen line 打开 new with div
原文地址:http://www.cnblogs.com/ljs1120/p/6917682.html