Python学习第四天——文件修改

2018-06-18 02:26:02来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

 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()
View Code

文件

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

  

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:[原创软件]PC端与移动端文件信息互通工具

下一篇:模拟实现ATM与购物商城