Ip address

Adam adamgarstang at googlemail.com
Sun Jan 28 08:21:50 EST 2007


Hey,

This will get your IP address:

#######Code########
print socket.gethostbyaddr(socket.gethostname())
('compname', [], ['192.168.1.2'])
########End Code########

If you are wanting to to communicate over the internet you will have 
to get the IP of you rounter. So you will have to either find a way to 
talk to your router or try and use an online service like these other 
guys suggest.

On Jan 28, 9:54 am, Scripter47 <nos... at riddergarn.dk> wrote:
> How do i get my ip address?
>
> in cmd.exe i just type "ipconfig" then it prints:
>       ...
>       IP-address . . . . . . . . . . . . . . . . . : 192.168.1.10
>       ...
> how can i do that in python??




More information about the Python-list mailing list