Posted By

oznek on 04/16/10


Tagged

python network ip detect discover


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

vkolev
gartenstuhl
magna


How to find out your IP address in Python


 / Published in: Python
 

URL: http://commandline.org.uk/python/how-to-find-out-ip-address-in-python/

  1. import socket
  2. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  3. s.connect(('google.com', 0))
  4. s.getsockname()[0]

Report this snippet  

You need to login to post a comment.