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
-- http://mail.python.org/mailman/listinfo/python-list