[Tutor] String or Re
Terry Carroll
carroll at tjc.com
Fri Jul 13 20:45:32 CEST 2007
On Fri, 13 Jul 2007, Que Prime wrote:
> I'm working on the following code to read a log file and output lines
> containing '10.52.10.10' but am unsure of whether to use a regular
> expression or string to achive this.
> for line in infile:
> if line #contains '10.52.10.10':
> outfile.write(line)
I wouldn't go with regular expressions here.
Try this:
for line in infile:
if line.find("10.52.10.11") != -1:
outfile.write(line)
More information about the Tutor
mailing list