阅读背景:

python基础实现简单的shell sed 替换功能

来源:互联网 
#coding:utf-8
from pygame.draw import lines
import sys,os
old_file = sys.argv[1]  #接受外部设备上的参数
new_file = sys.argv[2]
old_yes=open('yes.txt','r')
replace_yes=open('yes1.txt','a+')
lines=old_yes.readlines()   #将硬盘中的文件内容赋值给内存变量
# print lines
for line in lines:
#     print '1111111'
    if old_file in line:
         line=line.replace(old_file,new_file)  #替换字符
    replace_yes.write(line)
old_yes.close()
replace_yes.close()#coding:utf-8
from pygame.draw import l



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: