python --获取本机mac地址/本机IP
本机mac地址
import uuid
import json
def mac():
_mac = uuid.UUID(int=uuid.getnode()).hex[-12:]
return json.dumps({"code": 0, 'msg': 'success', 'mac': ":".join([mac[e:e + 2] for e in range(0, 11, 2)])})
本机IP地址
import socket
# 获取主机名
hostname = socket.gethostname()
# 获取IP
ip = socket.gethostbyname(hostname)
print("主机名:",hostname)
print("IP:",ip)