spliting on ":"

Cyril Bazin cyril.bazin at info.unicaen.fr
Sat Mar 4 21:05:31 CET 2006

Your file looks like a list of IP adresses.
You can use the urllib and urllib2 modules to parse IP adresses.

import urllib2
for line in open("fileName.txt"):
    addr, port  = urllib2.splitport(line)
    print (port != None) and '' or port

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060304/c3c12a92/attachment.html>

More information about the Python-list mailing list