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('188.8.131.52') 3555336315L >>> ipstring(_) '184.108.40.206' >>>
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.