formatting - Python converting ip address to ip number? -


In order to extract the organization name associated with them from MaxMand database, I am running on several types of IPs. I want to start with the IP, and say, continue till the name of organization like ips and then print the boundary! Def incrementIP (ip): If ip == '224.0.0.0': return 'end' nip = struct.unpack ('>', socket.inet_aton (ip)). [0] # this line transmitted IP string to number + nip + = 1 ip = socket.inet_ntoa (struct .pack ('& gt; I', nip)) #This row returns IP (IP) = {} IP address = In '0.0.0.1' the number varies, whereas the IPDress! = 'End': org = (gi.org_by_addr) d.setdefault (org, []) attachments (gi.range_by_ip (ipdress)) IPaddress = incrementIP (gi.range_by_ip (ipdress) [1])

And here is an error I get

  ------------------------- ---------- ---------------------------------------- Error traceback (most recent call final) & lt; IPython-Input-16-a010e0aa70ac & gt; In & lt; Module & gt; () 4 ​​ORG = (gi.org_by_addr) (IPdress) 5D.SetDefault (ORG, []) .andand (G.ange_b_IP (ipdress)) ---- & gt; 6 IPdress = Working IP (G.ange_by_ip (ipd) [1]) 7 # print (d) 8 ipiethon-input-14-0 b 40331d 68 c & gt; In incrementIP (ip) 7 nip = struct.unpack ('& gt; I', socket.inet_aton (ip)) [0] # this line interactive IP string is equal to number 8 nip + = 1 ---- & gt; 9 ip = socket.inet_ntoa (struct.pack ('& gt; I', nip)) #This line changes the number back from IP10 return (IP) error: 0 in the 'I' format & lt; = Number & lt; = 4294967295  

I did not know why I got this error, can anyone help me with this?

Remove the name of the organization associated with them from the Maxmind database For many types of IPs, I want to start with the first IP in the IP space, and say, continue till the name of the organization like ips and then print the boundary! Def incrementIP (ip): If ip == '224.0.0.0': return 'end' nip = struct.unpack ('>', socket.inet_aton (ip)). [0] # this line transmitted IP string to number + nip + = 1 ip = socket.inet_ntoa (struct .pack ('& gt; I', nip)) #This row returns IP (IP) = {} IP address = In '0.0.0.1' the number varies, whereas the IPDress! = 'End': org = (gi.org_by_addr) d.setdefault (org, []) attachments (gi.range_by_ip (ipdress)) IPaddress = incrementIP (gi.range_by_ip (ipdress) [1])

And here is an error I get

  ------------------------- ---------- ---------------------------------------- Error traceback (most recent call final) & lt; IPython-Input-16-a010e0aa70ac & gt; In & lt; Module & gt; () 4 ​​ORG = (gi.org_by_addr) (IPdress) 5D.SetDefault (ORG, []) .andand (G.ange_b_IP (ipdress)) ---- & gt; 6 IPdress = Working IP (G.ange_by_ip (ipd) [1]) 7 # print (d) 8 ipiethon-input-14-0 b 40331d 68 c & gt; In incrementIP (ip) 7 nip = struct.unpack ('& gt; I', socket.inet_aton (ip)) [0] # this line interactive IP string is equal to number 8 nip + = 1 ---- & gt; 9 ip = socket.inet_ntoa (struct.pack ('& gt; I', nip)) #This line changes the number back from IP10 return (IP) error: 0 in the 'I' format & lt; = Number & lt; = 4294967295  

I did not know why I got this error, can anyone help me with this?


Comments

Popular posts from this blog

graphviz - size of node with shape=circle -

android - TCP sending with Unity -

properties - C#: How to set default value for a property in a partial class? -