1 import sys 2 3 f=open('lyrics.txt','r',encoding='utf-8') #读写 4 f_new=open('lyrics_new','w+',encoding='utf-8') 5 find_str=sys.argv[1] 6 replace_str=sys.argv[2] 7 for line in f: 8 if find_str in line: 9 line=line.replace(find_str,replace_str) 10 f_new.write(line) 11 f.close() 12 f_new.close()