[Tutor] String or Re

Que Prime queprime at gmail.com
Fri Jul 13 20:04:17 CEST 2007


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.  Can someone please enlighten me? Thank
you.


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

for line in infile:
    if line #contains '10.52.10.10':
        outfile.write(line)


ofile.close()
wfile.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070713/d72c6fd6/attachment.htm 


More information about the Tutor mailing list