#/usr/bin/env
#coding:utf8
import os,sys
#使用提示
args=len(sys.argv)
if not 3<=args<=5:
print "输入格式:python test.py 被替换字符 替换字符 源文件 目标输出文件"
else:
readed_file = sys.stdin
writed_file = sys.stdout
origin_string = sys.argv[1]
replace_string = sys.argv[2]
if args >3:
readed_file = open(sys.argv[3])
if args>4:
writed_file = open(sys.argv[4],'w')
for s in readed_file:
writed_file.write(s.replace(origin_string,replace_string))
readed_file.close()
writed_file.close()
阅读(1583) | 评论(0) | 转发(0) |