当前位置: 移动技术网 > IT编程>脚本编程>Python > Python学习第四天——文件修改

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

2018年04月18日  | 移动技术网IT编程  | 我要评论

玫琳凯首席张曼曼,13524答案不是6,文强睡过的女明星完全榜单

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

  

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网