[Tutor] File parse

Que Prime queprime at gmail.com
Tue Jul 17 17:09:45 CEST 2007


I'm trying to parse a file and extract 'src=172.16.148.27 dst=10.52.10.10'
out of each line that contains 10.52.10.10, but get lost with writing the
information and am not sure if I should .re at all.


import re

infile = open("in.txt","r")
outfile = open("out.txt", "w")

for line in infile:
    re.match('src=*10.52.10.10')
        outfile.write(re.compile)


ofile.close()
wfile.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070717/429a259e/attachment.html 


More information about the Tutor mailing list