python废话五:python获取本机信息

python 获得本机MAC地址:

def get_mac():
    mac = uuid.UUID(int = uuid.getnode()).hex[-12:]
    mac_address = ":".join([mac[e:e+2] for e in range(0,11,2)])
    return mac_address

python获取本机ip地址:

def get_ip_config():
    name = socket.getfqdn(socket.gethostname())
    ipaddress = socket.gethostbyname(name)
    return "computer_name:"+name+",computer_ip:"+ipaddress


你可能感兴趣的:(python废话五:python获取本机信息)