Last active
December 26, 2015 07:09
-
-
Save vipwp/7112609 to your computer and use it in GitHub Desktop.
python get IP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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