def ip2long1(ip):
hexn = ''.join(["%02X" % long(i) for i in ip.split('.')])
return long(hexn, 16)
def ip2long2(ip):
lngip = 0
for q in ip.split('.'):
lngip = (lngip << 8) | int(q)
return lngip
if __name__ == '__main__':
print ip2long1("173.230.156.208")
print ip2long2("173.230.156.208")
-----------
post by gmail~
暂时没有留言。