zoukankan      html  css  js  c++  java
  • Python学习第四天——文件修改

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

      

  • 相关阅读:
    13-计算属性和侦听器
    12-指令系统介绍
    11-vue的使用
    10-vue的介绍
    09-babel
    08-webpack的介绍
    07-nodejs中npm的使用
    06-Nodejs介绍
    05-面向对象
    Docker结合Jenkins构建持续集成环境
  • 原文地址:https://www.cnblogs.com/yongor/p/8869920.html
Copyright © 2011-2022 走看看