方法一:
pip install netaddr
from netaddr import *
mac = EUI(0x05056bdafc)
print (mac)
mac.dialect = mac_unix
print (mac)
方法二:
from pysnmp.smi import builder
mibBuilder = builder.MibBuilder()
MacAddress, = mibBuilder.importSymbols('SNMPv2-TC', 'MacAddress')
macAddress = MacAddress(hexValue='05056bdafc'.zfill(12))
macAddress.prettyPrint()
方法三:
mac = '05056bdafc'.zfill(12)
':'.join([ mac[i:i+2] for i in range(0, 12, 2) ])
文章评论