Created
January 6, 2015 03:14
-
-
Save oldj/b5e36cd6d0972718e36e to your computer and use it in GitHub Desktop.
取得IP地址及主机名
This file contains hidden or 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
import socket | |
name = socket.gethostname() | |
ip_addr = socket.gethostbyname(name) | |
print name | |
print ip_addr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment