1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 ############################4 #File Name:getmac.py5 #Author:frank6 #Mail: [email protected]7 #Created time:2017-06-05 17:10:518 ############################9 Ten ImportUUID One A defget_mac_address (): -Mac=uuid. UUID (int = Uuid.getnode ()). hex[-12:].upper () - #return '%s:%s:%s:%s:%s:%s '% (mac[0:2],mac[2:4],mac[4:6],mac[6:8],mac[8:10],mac[10:]) the return ":". Join ([mac[e:e+2] forEinchRange (0,11,2)]) - - if __name__=='__main__': - ##name = "Test_name" + #namespace = "Test_namespace" - + Printget_mac_address () A " " at U=uuid.uuid1 () # method with parameters see Python Doc - Print U - #print uuid.uuid3 (namespace, name) - #print uuid.uuid4 () - #print Uuid.uuid5 (namespace, name) - Node1=uuid.getnode () #获取mac地址 in print ("node1:%s"%node1) - print ("Hex (node1):%s"%hex (Node1)) to print ("uuid.bytes:%s"%repr (u.bytes)) + print ("uuid.bytes_le:%s"%repr (u.bytes_le)) - print ("Hex:", U.hex) the print ' int: ', U.int * print ' urn: ', U.urn $ print ' variant: ', U.variantPanax Notoginseng print ' version: ', U.version - #print get_mac_address () the " "
python-get the native MAC address