获取主机名

#!/usr/bin/env python
# encoding: utf-8

# 查看主机名
import socket
def gethostname():
        hostname = socket.gethostname()
        return hostname

ret = gethostname()
print(ret)
原文地址:https://www.cnblogs.com/huxl1/p/15662132.html