Skip to content

Instantly share code, notes, and snippets.

@vipwp
Last active December 26, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vipwp/7112609 to your computer and use it in GitHub Desktop.
Save vipwp/7112609 to your computer and use it in GitHub Desktop.
python get IP
def getip():
localIP = socket.gethostbyname(socket.gethostname())#得到本地ip
print "local ip:%s " % localIP
ipList = socket.gethostbyname_ex(socket.gethostname())
for i in ipList:
if i != localIP:
print "external IP:%s" % i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment