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


Cyril
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to