Skip to content

Instantly share code, notes, and snippets.

@ami-GS
Created January 24, 2014 09:25
Show Gist options
  • Select an option

  • Save ami-GS/8594430 to your computer and use it in GitHub Desktop.

Select an option

Save ami-GS/8594430 to your computer and use it in GitHub Desktop.
ローカルIPアドレスとグローバルIPアドレスが知りたいとき
import urllib
import socket
def getLocalIP():
return socket.gethostbyname(socket.gethostname())
def getGrobalIP():
sock = urllib.urlopen("http://ipcheck.ieserver.net/")
ip = sock.read()
sock.close()
return ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment