Host name: ubuntu IP address:127.0.1.1
# 获取主机名 hostname=socket.gethostname() # 获取IP ip=socket.gethostbyname(hostname) # 获取Mac地址 defget_mac_address(): mac=uuid.UUID(int=uuid.getnode()).hex[-12:] return":".join([mac[e:e+2]foreinrange(0,11,2)]) print("主机名:",hostname) print("IP:",ip) print("Mac地...
简介: python自带模块获取服务器主机名称、IP地址和mac地址 # -*- coding: UTF-8 -*- # @Time : 2021-08-24 9:53 # @File : index.py # @Author : LockDataV import socket import uuid # 获取主机名 hostname = socket.gethostname() # 获取IP ip = socket.gethostbyname(hostname) # 获取Mac...
简介:python自带模块获取服务器主机名称、IP地址和mac地址 # -*- coding: UTF-8 -*-# @Time : 2021-08-24 9:53# @File : index.py# @Author : LockDataVimport socketimport uuid# 获取主机名hostname = socket.gethostname()# 获取IPip = socket.gethostbyname(hostname)# 获取Mac地址def get_mac_a...