1 #coding=utf-8 2 #Version:python 3.6.0 3 #Tools:Pycharm 2017.3.2 4 _date_ = '2018/4/17/017 20:38' 5 _author_ = 'Hongyong' 6 7 f = open("yesterday","r",encoding="utf-8") 8 f_new = open("yesterday2","w",encoding="utf-8") 9 10 for line in f: 11 if "肆意的快乐等我享受" in line: 12 line = line.replace("肆意的快乐等我享受" ,"肆意的快乐等洪勇享受") 13 f_new.write(line) 14 f.close() 15 f_new.close()
文件
Oh, yesterday when I was young 噢 昨日当我年少轻狂 So many, many songs were waiting to be sung 有那么那么多甜美的曲儿等我歌唱 So many wild pleasures lay in store for me 有那么多肆意的快乐等我享受 And so much pain my eyes refused to see 还有那么多痛苦 我的双眼却视而不见 There are so many songs in me that won't be sung 我有太多歌曲永远不会被唱起 I feel the bitter taste of tears upon my tongue 我尝到了舌尖泪水的苦涩滋味 The time has come for me to pay for yesterday 终于到了付出代价的时间 为了昨日 When I was young 当我年少轻狂