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
当我年少轻狂

最新文章

  1. 国内git项目托管平台
  2. ora-00119和ora-00132解决方案
  3. 编写Java应用程序。首先,定义一个Print类,它有一个方法void output(int x),如果x的值是1,在控制台打印出大写的英文字母表;如果x的值是2,在 控制台打印出小写的英文字母表。其次,再定义一个主类——TestClass,在主类 的main方法中创建Print类的对象,使用这个对象调用方法output ()来打印出大 小写英文字母表。
  4. HDU2191(多重背包)
  5. 打造移动终端的 WebApp(一):搭建一个舞台
  6. JQuery:JQuery操作CSS类
  7. 直接拿来用!超实用的Java数组技巧攻略[转]
  8. Android---WebView显示Html乱码问题
  9. [HDU 1254] 推箱子
  10. 关于在Reshaper中添加代码模板代码段
  11. 百度云BAE3.0 的ssh构造(本机ssh项目迁移到BAE3.0)
  12. 【IE6的疯狂之十三】IE6下使用滤镜后链接不能点击的BUG
  13. window.open页面关闭后刷新父页面
  14. [Educational Round 10][Codeforces 652F. Ants on a Circle]
  15. redis解决高并发下脏读问题
  16. beta3
  17. Swift语言精要 - 属性
  18. CNN autoencoder 进行异常检测——TODO,使用keras进行测试
  19. .net core 生成二维码
  20. day 70 crm(7):stark组件调用,以及权限分配

热门文章

  1. 浅谈关于collection接口及相关容器类(一)
  2. STM32F407VG (四)时钟配置
  3. jdbc14 及 jdbc16 共存所带来的问题【未完待续】
  4. 前端防止button被多次点击
  5. [JZOJ 4307] [NOIP2015模拟11.3晚] 喝喝喝 解题报告
  6. [LeetCode] 2. Add Two Numbers 两个数字相加 java语言实现 C++语言实现
  7. NOIP2012 T3开车旅行 set+倍增
  8. Linux java9 jshell操作
  9. jqGrid收藏的链接
  10. 让placeholder中的默认文字居中,或者缩进多少像素