字符串mac地址转换:
def str2mac(s):
return ("%02x:" * 6)[:-1] % tuple(orb(x) for x in s)
mac地址转字符串:
def mac2str(mac):
return b"".join(chb(int(x, 16)) for x in plain_str(mac).split(':'))
参考链接:
https://github.com/secdev/scapy/blob/2e87889089e5593988911309bb4a1ca4f632d716/scapy/utils.py#L467