import socket
import uuid

# 获取主机名
hostname = socket.gethostname()
#获取IP
ip = socket.gethostbyname(hostname)
# 获取Mac地址
def get_mac_address():
    mac=uuid.UUID(int = uuid.getnode()).hex[-12:]
    return ":".join([mac[e:e+2] for e in range(0,11,2)])

# ipList = socket.gethostbyname_ex(hostname)
# print(ipList)
print("主机名:",hostname)
print("IP:",ip)
print("Mac地址:",get_mac_address())

原文链接:https://blog.csdn.net/lm_is_dc/article/details/80437053

 

相关文章:

  • 2021-12-02
  • 2021-11-27
  • 2021-11-17
  • 2021-12-28
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2021-06-04
  • 2022-12-23
  • 2021-12-05
  • 2022-02-13
  • 2022-12-23
  • 2021-12-20
  • 2022-01-16
相关资源
相似解决方案