Ip address

Adonis Vargas adonis at REMOVETHISearthlink.net
Sun Jan 28 22:19:53 EST 2007


Scripter47 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??
> 

If you want to get your external IP you can do:

import urllib

checkIP = urllib.urlopen("http://checkip.dyndns.org").read()
externalIP = checkIP.split()[-1].strip("</body></html>")
print externalIP

Hope this helps.

Adonis



More information about the Python-list mailing list