于一 发表于 2018-8-12 09:30:12

python语言实现mac地址自加

import struct  
def 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]
查看完整版本: python语言实现mac地址自加