标签:blog pen nbsp class yesterday odi 报错 open 修改
f = open("yesterday","r",encoding="utf-8") f_new=open("yesterday2.bak","w",encoding="utf-8") for line in f: if "等待我最喜爱的歌" in line: line = line.replace("等待我最喜爱的歌","等待Alex最喜爱的歌") f_new.write(line) f.close() #要注意跳出for循环再close,否则会报错 f_new.close()
标签:blog pen nbsp class yesterday odi 报错 open 修改
原文地址:http://www.cnblogs.com/xiaobai005/p/7805881.html