#! /usr/bin/env python

import sys,os

FilePath
= 'd:/SVNtest/'
FileName
= FilePath + 'error.log'
ResultFile
= FilePath + 'Fail.log'
KeyWord
= 'error'

try:
fh
= open(FileName,'r')
allLines
= fh.readlines()
fh.close()
except IOError:
print "the file don't exist, Please double check!"

i
= 0
counter
= 0
NewLines
= []

for oneLine in allLines:
i
+= 1
if oneLine.find(KeyWord) >= 0:
counter
+=1
print 'Find the match line at %d,now total %d times' %(i,counter)
NewLines.append(oneLine)


fh
= open(ResultFile,'a')
fh.writelines(NewLines)
fh.close()

 

相关文章:

  • 2022-12-23
  • 2021-07-10
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
  • 2021-06-24
  • 2021-10-30
  • 2022-12-23
猜你喜欢
  • 2021-08-18
  • 2022-12-23
  • 2021-05-09
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
  • 2022-12-23
相关资源
相似解决方案