IP address to binary conversion

al.alexiev at gmail.com al.alexiev at gmail.com
Fri May 8 20:19:20 EDT 2020


Just for the records and to have a fully working bidirectional solution:

>>> ip
'10.44.32.0'
>>> struct.unpack('L', socket.inet_aton(ip))[0]
2108426
>>> socket.inet_ntoa(struct.pack('<L', 2108426))
'10.44.32.0'
>>>

Good luck ;-)


More information about the Python-list mailing list