[Tutor] Detecting my own IP address?

Terry Carroll carroll at tjc.com
Sun Jun 5 10:32:55 CEST 2005


The Python Cookbook (1st ed) suggests this, in recipe 10.4 ("Finding Your 
Own Name and Address):

>>> import socket
>>> myname = socket.getfqdn(socket.gethostname())
>>> myaddr = socket.gethostbyname(myname)
>>> myaddr
'192.168.1.120'






More information about the Tutor mailing list