获取mac地址:
import uuiddef get_mac_address():mac=uuid.UUID(int = uuid.getnode()).hex[-12:]return ":".join([mac[e:e+2] for e in range(0,11,2)])if __name__ == '__main__':print(get_mac_address())
获取IP地址和主机名:
import socketpcname = socket.getfqdn(socket.gethostname( ))pcip = socket.gethostbyname(pcname)print(pcname)print(pcip)