文件搜索替换

 

#将c:\\a.txt文件中的001替换为MM
for l in fileinput.input("c:\\a.txt",inplace=1):
  nl = l.replace('001','MM')
  print nl  #该句必须要存在,用于写入文件,否则文件会为空

 

posted on 2016-04-23 18:52  momingliu11  阅读(195)  评论(0编辑  收藏  举报