python语言实现mac地址自加
import structdef macs2a(mac):
dict = {'0':0, '1':1, '2':2, '3':3, '4':4,\
'5':5, '6':6, '7':7, '8':8, '9':9,\
'a':10, 'b':11, 'c':12, 'd':13, 'e':14, 'f':15}
mac = mac.lower()
tmp = mac.split(':')
res = ''
for i in range(len(tmp)):
uc = struct.pack('B', 16*dict] + dict])
res = res + uc
return res
页:
[1]