python获得本机机器名

import sys, socket

hostname = socket.gethostname()
# Try to get the fully-qualified name.
print 'Fully-qualified name:', socket.getfqdn(hostname)

编程技巧