python_40_通过脚本转换参数实现替换

import sys
f=open('yesterday','r',encoding='utf-8')
f_new=open('yesterday_update','w',encoding='utf-8')
find_str=sys.argv[1]
replace_str=sys.argv[2]
for line in f:
    if find_str in line:
        line=line.replace(find_str,replace_str)#.replace(旧,新)  替换的用法
    f_new.write(line)
f.close()
f_new.close()

  

posted @ 2018-01-20 20:56  耐烦不急  阅读(374)  评论(0编辑  收藏  举报