C
Chris
How do I find and print to screen the IP address of the computer my
python program is working on?
python program is working on?
Chris said:How do I find and print to screen the IP address of the computer my
python program is working on?
import socket
socket.getaddrinfo(socket.gethostname(), None)[0][4][0]
Chris said:hehe, works a charm, cheers mate.
IP adresses are bound to network interfaces not to computers.
One Computer can have multiple network interfaces.
Grant Edwards said:And each interface can have any number if IP addresses
(including none).
Chris said:How do I find and print to screen the IP address of the computer my
python program is working on?
DarkBlue said:Chris wrote:
How do I find and print to screen the IP address of the computer my
python program is working on?
def readip():
import re, urllib
f = urllib.urlopen('http://checkip.dyndns.org')
s = f.read()
m = re.search('([\d]*\.[\d]*\.[\d]*\.[\d]*)', s)
return m.group(0)
myip = readip()
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.