Results not quite what I expected

Kemp Randy-W18971 Randy.L.Kemp at motorola.com
Mon Apr 2 15:28:31 EDT 2001


Alex:
   I tried your suggestion, and I am close, but not quite.  What is happening with the number split?

Here is my code:

import string, sys, os, re

if __name__ == "__main__":
    Max_lines = 7
    InputFileName = os.path.join("d:", "programsPython", "test.txt")
    OutputFileName = os.path.join("d:", "programsPython", "outdata.txt")
    fout = open(OutputFileName, 'w')
    fin = open(InputFileName, 'r')
    number = re.compile(r'\d+\.?d*')
    rawtext = fin.read()
    for anumber in number.findall(rawtext):
        print "Number is: " + repr(anumber) + "\n"
    fin.close()
    fout.close()  

Here is my output:

>>> Number is: '4'

Number is: '4.'

Number is: '00'

Number is: '5598'

Number is: '80.'

Number is: '10'

Here is my input file:

Min. line width (mils):                 4
4.00 mils trace segment count / % of total:    5598/80.10 %
 




More information about the Python-list mailing list