def ipnumber(ip): ip=ip.rstrip().split('.') ipn=0 while ip: ipn=(ipn<<8)+int(ip.pop(0)) return ipn def ipstring(ip): ips='' for i in range(4): ip,n=divmod(ip,256) ips = str(n)+'.'+ips return ips[:-1] ## take out extra point >>> ipnumber('220.127.116.11') 3555336315L >>> ipstring(_) '18.104.22.168' >>>
Edited by pyTony: empty line
Are you able to help answer this sponsored question?
Questions asked by members who have earned a lot of community kudos are featured in order to give back and encourage quality replies.