zoukankan      html  css  js  c++  java
  • 修改文件中的某个字段

    如:将 “夜晚的” 改为 “白天的寒冷的”

     1 Somehow, it seems the love I knew was always the most destructive kind
     2 不知为何,我经历的爱情总是最具毁灭性的的那种
     3 Yesterday when I was young
     4 昨日当我年少轻狂
     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 就如夜晚的微风
     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()
  • 相关阅读:
    smb 共享文件夹
    php nginx 配置
    mysql 存储过程
    ubuntu 源码下载分析
    rust 小米R3G官方rom(openwrt) openssl
    rust 配置
    mac 制作树莓派3b启动盘
    小米R2D
    golang 配置
    golang pprof操作流程
  • 原文地址:https://www.cnblogs.com/wangmo/p/6128962.html
Copyright © 2011-2022 走看看