how to convert ip address to dot notation

Tino Lange tl_news at nexgo.de
Mon Aug 4 09:56:48 EDT 2003


Ruslan Spivak wrote:
 
> I have ip addresses in my mysql db in int value - 3232261127, for example.
> How can i convert that to usual dot notation like 192.168.100.7?

Hi Ruslan!

The socket Module conatins some magic for that:

>>> import socket, struct
>>> socket.inet_ntoa(struct.pack('!L',3232261127L))

'192.168.100.7'

Cheers

Tino





More information about the Python-list mailing list