shell sed 替換功能 要替換的文件: ...
shell sed 替換功能
f1 = open('yesterday','r',encoding='utf-8')
f2 = open('yesterday2','w',encoding='utf-8')
for line in f1:
if '噢 昨日當我年少輕狂'in line:
line = line.replace('噢 昨日當我年少輕狂','啦啦啦啦啦啦啦啦啦')
f2.write(line)
f1.close()
f2.close()
要替換的文件:
Somehow, it seems the love I knew was always the most destructive kind
不知為何,我經歷的愛情總是最具毀滅性的的那種
Yesterday when I was young
昨日當我年少輕狂
The taste of life was sweet
生命的滋味是甜的
As rain upon my tongue
就如舌尖上的雨露
I teased at life as if it were a foolish game
我戲弄生命 視其為愚蠢的游戲
The way the evening breeze
就如夜晚的微風
May tease the candle flame
逗弄蠟燭的火苗
The thousand dreams I dreamed
我曾千萬次夢見
The splendid things I planned
那些我計劃的絢麗藍圖
I always built to last on weak and shifting sand
但我總是將之建築在易逝的流沙上
I lived by night and shunned the naked light of day
我夜夜笙歌 逃避白晝赤裸的陽光
And only now I see how the time ran away
事到如今我才看清歲月是如何匆匆流逝
Yesterday when I was young
昨日當我年少輕狂
So many lovely songs were waiting to be sung
有那麼多甜美的曲兒等我歌唱
So many wild pleasures lay in store for me
有那麼多肆意的快樂等我享受
And so much pain my eyes refused to see
還有那麼多痛苦 我的雙眼卻視而不見
I ran so fast that time and youth at last ran out
我飛快地奔走 最終時光與青春消逝殆盡
I never stopped to think what life was all about
我從未停下腳步去思考生命的意義
And every conversation that I can now recall
如今回想起的所有對話
Concerned itself with me and nothing else at all
除了和我相關的 什麼都記不得了
The game of love I played with arrogance and pride
我用自負和傲慢玩著愛情的游戲
And every flame I lit too quickly, quickly died
所有我點燃的火焰都熄滅得太快
The friends I made all somehow seemed to slip away
所有我交的朋友似乎都不知不覺地離開了
And only now I'm left alone to end the play, yeah
只剩我一個人在臺上來結束這場鬧劇
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
當我年少輕狂