IP address
Klaus Alexander Seistrup
klaus at seistrup.dk
Sun Jan 28 08:40:30 EST 2007
Adam wrote:
> This will get your IP address:
>
> #######Code########
> print socket.gethostbyaddr(socket.gethostname())
> ('compname', [], ['192.168.1.2'])
> ########End Code########
It will return an IP address, but not necessarily the one you want:
#v+
klaus at home:~ $ python -c 'import socket; print socket.gethostbyaddr(socket.gethostname())'
('zdani.szn.dk', [], ['2001:1448:89::1'])
klaus at home:~ $
#v-
Cheers,
--
Klaus Alexander Seistrup
http://klaus.seistrup.dk/
More information about the Python-list
mailing list