#逐行读写f = open('yesterday','r',encoding='utf-8')f_new = open('yesterday3','w',encoding="utf-8")for line in f: if '等我享受' in line: line = line.replace('等我享受','等lian享受') f_new.write(line)f.close()f_new.close()