Skip to content

Instantly share code, notes, and snippets.

@oldj
Created January 6, 2015 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save oldj/b5e36cd6d0972718e36e to your computer and use it in GitHub Desktop.
Save oldj/b5e36cd6d0972718e36e to your computer and use it in GitHub Desktop.
取得IP地址及主机名
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