文件搜索替换

#将c:\a.txt文件中的001替换为MM
for l in fileinput.input("c:\a.txt",inplace=1):
  nl = l.replace('001','MM')
  print nl  #该句必须要存在,用于写入文件,否则文件会为空
原文地址:https://www.cnblogs.com/dreamer-fish/p/5425271.html