[Tutor] File parse
Tiger12506
keridee at jayco.net
Tue Jul 17 23:14:48 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.
Could you send a few lines of "in.txt"? I can help better.
> import re
>
> infile = open("in.txt","r")
> outfile = open("out.txt", "w")
>
> for line in infile:
> re.match('src=*10.52.10.10')
This will not help you whatsoever. You will have to check the return of
re.match. Also, I suspect that your re pattern could use some tweaking.
Those lines from your file?
More information about the Tutor
mailing list