Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Python: check if a file has any lines that end with digits

Python: check if a file has any lines that end with digits
{filelink=16045}

__author__="sako"
__date__ ="$6 oct. 2012 13:05:19$"
import re
def fileEndWith(filename):
    end_with_digit = re.compile(r'd$', re.MULTILINE)
    if end_with_digit.search(open(filename).read( )):
       print "some lines end with digits"
    else:
       print "no lines end with digits"
if __name__ == "__main__":
    fileEndWith("c:/test.txt")

Users who found this page were searching for:

  • python add entry to dict
  • python checking if a key exist

No comments yet.

Leave a Comment