修改文件中的某个字段
生活随笔
收集整理的這篇文章主要介紹了
修改文件中的某个字段
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
如:將 “夜晚的” 改為 “白天的寒冷的”
1 Somehow, it seems the love I knew was always the most destructive kind 2 不知為何,我經(jīng)歷的愛情總是最具毀滅性的的那種 3 Yesterday when I was young 4 昨日當(dāng)我年少輕狂 5 The taste of life was sweet 6 生命的滋味是甜的 7 As rain upon my tongue 8 就如舌尖上的雨露 9 I teased at life as if it were a foolish game 10 我戲弄生命 視其為愚蠢的游戲 11 The way the evening breeze 12 就如夜晚的微風(fēng) 1 f = open("lyrics","r",encoding="utf-8") 2 f2 = open("lyrics_new","w",encoding="utf-8") 3 4 find_str= "夜晚的" 5 new_str = "白天的寒冷的" 6 for line in f: 7 if find_str in line: 8 line = line.replace(find_str,new_str) 9 f2.write(line) 10 11 f.close() 12 f2.close()?
轉(zhuǎn)載于:https://www.cnblogs.com/wangmo/p/6128962.html
總結(jié)
以上是生活随笔為你收集整理的修改文件中的某个字段的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 苹果cmsV10高端大气简洁网站模板带后
- 下一篇: 带你玩转kubernetes-k8s(第