python 3.x 写 shell sed 替换功能
shell sed 替换功能
- f1 = open('yesterday','r',encoding='utf-8')
- f2 = open('yesterday2','w',encoding='utf-8')
- for line in f1:
- if '噢 昨日当我年少轻狂'in line:
- line = line.replace('噢 昨日当我年少轻狂','啦啦啦啦啦啦啦啦啦')
- f2.write(line)
- f1.close()
- f2.close()
要替换的文件:
- Somehow, it seems the love I knew was always the most destructive kind
不知为何,我经历的爱情总是最具毁灭性的的那种
Yesterday when I was young
昨日当我年少轻狂
The taste of life was sweet
生命的滋味是甜的
As rain upon my tongue
就如舌尖上的雨露
I teased at life as if it were a foolish game
我戏弄生命 视其为愚蠢的游戏
The way the evening breeze
就如夜晚的微风
May tease the candle flame
逗弄蜡烛的火苗
The thousand dreams I dreamed
我曾千万次梦见
The splendid things I planned
那些我计划的绚丽蓝图
I always built to last on weak and shifting sand
但我总是将之建筑在易逝的流沙上
I lived by night and shunned the naked light of day
我夜夜笙歌 逃避白昼赤裸的阳光
And only now I see how the time ran away
事到如今我才看清岁月是如何匆匆流逝
Yesterday when I was young
昨日当我年少轻狂
So many lovely songs were waiting to be sung
有那么多甜美的曲儿等我歌唱
So many wild pleasures lay in store for me
有那么多肆意的快乐等我享受
And so much pain my eyes refused to see
还有那么多痛苦 我的双眼却视而不见
I ran so fast that time and youth at last ran out
我飞快地奔走 最终时光与青春消逝殆尽
I never stopped to think what life was all about
我从未停下脚步去思考生命的意义
And every conversation that I can now recall
如今回想起的所有对话
Concerned itself with me and nothing else at all
除了和我相关的 什么都记不得了
The game of love I played with arrogance and pride
我用自负和傲慢玩着爱情的游戏
And every flame I lit too quickly, quickly died
所有我点燃的火焰都熄灭得太快
The friends I made all somehow seemed to slip away
所有我交的朋友似乎都不知不觉地离开了
And only now I'm left alone to end the play, yeah
只剩我一个人在台上来结束这场闹剧
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
当我年少轻狂
python 3.x 写 shell sed 替换功能的更多相关文章
- Python3学习之路~2.8 文件操作实现简单的shell sed替换功能
程序:实现简单的shell sed替换功能 #实现简单的shell sed替换功能,保存为file_sed.py #打开命令行输入python file_sed.py 我 Alex,回车后会把文件中的 ...
- 3-1 实现简单的shell sed替换功能
1.需求 程序1: 实现简单的shell sed替换功能 file1 的内容copy到file2 输入参数./sed.py $1 $2 $1替换成$2 (把a替换成% ) 2.个人思路 open ...
- 4.实现简单的shell sed替换功能
# -*- coding:utf-8 -*- # Author: JACK ZHAO # 程序1: 实现简单的shell sed替换功能 import sys #判断参数个数 if len(sys.a ...
- Python3.5 day3作业一:实现简单的shell sed替换功能
需求: 1.使python具有shell中sed替换功能. #!/usr/bin/env python #_*_conding:utf-8_*_ #sys模块用于传递参数,os模块用于与系统交互. i ...
- python基础实现简单的shell sed 替换功能
#coding:utf-8 from pygame.draw import lines import sys,os old_file = sys.argv[1] #接受外部设备上的参数 new_fil ...
- 实现简单的shell sed替换功能
通过脚本传参数可以实现替换 # -*-coding:utf-8-*- # Author:sunhao import sys f = open('yesterday','r',encoding='utf ...
- 第11.23节 Python 中re模块的搜索替换功能:sub及subn函数
一. 引言 在<第11.3节 Python正则表达式搜索支持函数search.match.fullmatch.findall.finditer>重点介绍了几个搜索函数,除了搜索,re模块也 ...
- 实现简单sed替换功能的python脚本
#可以用来修改配置文件参数 # -*- coding:utf-8 -*- import os,sys old = sys.argv[1] new = sys.argv[2] file = sys.ar ...
- python中写shell(转)
python中写shell,亲测可用,转自stackoverflow To run a bash script, copy from stackoverflow def run_script(scri ...
随机推荐
- Python中常见的文件对象内建函数
文件对象内建方法列表 文件对象的方法 操作 file.close() 关闭文件 file.fileno() 返回文件的描写叙述符(file descriptor.FD,整数值) file.flush( ...
- Android中文API-ViewStub
ViewStub控件是一个不可见,0尺寸得惰性控件.当ViewStub控件设置可见,或者调用inflate(),并运行完毕之后,ViewStub所指定的layout资源就会被载入.这个ViewStub ...
- OC 自己定义 setDateFormat 显示格式
-(NSString *)getStringFromDate:(NSDate *)aDate { NSDateFormatter *dateFormater=[[NSDateFormatter all ...
- Android学习之——自己搭建Http框架(2)——框架扩展
· 本文主要解说的是Json指定转化成对象返回.下载进度更新,随时取消Request请求 一.Json指定转化成对象返回 上篇文章主要讲基础的框架搭建起来了,这次须要做一些些的扩展,这里Json转化用 ...
- Process Monitor
https://en.wikipedia.org/wiki/Process_Monitor Process Monitor is a free tool from Windows Sysinterna ...
- CxImage学习
官方下载地址是:http://www.xdp.it/cximage/ 打开工程后可以看到下例这些工程: - CxImage - CxImageCrtDll - CxImageMfcDll - dome ...
- 《剑指offer》数组中出现次数超过一半的数字
一.题目描述 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字.例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}.由于数字2在数组中出现了5次,超过数组长度的一半,因此输出 ...
- exsi中的虚拟机添加磁盘后虚拟机中磁盘不出现
exsi中的虚拟机添加磁盘后虚拟机中磁盘不出现解决: 计算机---> 管理: 这里可以选择磁盘,格式,分区, 改盘符等操作
- tinymce原装插件源码分析(六)-preview
priview 此插件文件结构比较简单,按钮注册.editor.windowManager.open.窗口出现之前的渲染数据的准备.页面代码的准备. 注意: 1.preview的默认宽高设置: 2.c ...
- BZOJ 2141 排队(CDQ分治)
我们把每一次交换看做两个插入两个删除.然后就是一个三维偏序.时间一维,下标一维,权值一维. #include<iostream> #include<cstring> #incl ...