字符转码

#!usrinenvpython

import sys

f = open("yest2",'r',encoding="utf-8")

f_new= open("yest2.bak",'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)

f_new.write(line)

f_new.close()

f.close()

原文地址:https://www.cnblogs.com/lindong0602/p/9239549.html