reading a line in file

Shawn Milochik Shawn at Milochik.com
Mon Aug 20 21:07:02 CEST 2007


Hopefully this will help (using your input file)

#!/usr/bin/env python
import re
buildinfo = "input.txt"
input = open(buildinfo, 'r')

regex = re.compile(r"^\s*build.number=(\d+)\s*$")

for line in input:
    if re.search(regex, line):
        print line
        buildNum = re.sub(r"^\s*build.number=(\d+)\s*$", "\\1", line)
        print line
        print buildNum



More information about the Python-list mailing list