获取主机名

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

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

ret = gethostname()
print(ret)

 

posted @ 2021-12-08 16:15  huxl1  阅读(56)  评论(0编辑  收藏  举报