我尝试在python 3.6.2中获取Mac加法器,我编写了下面的代码来获取它:
xmlhttp.open("POST", "CorRex33.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//Your status change code
xmlhttp.send("WriteFridayHours="+WriteFridayHours);
但它打印错误,例如,如果我的Mac加法器是ff:ff:ff:ff:ff:12,它打印 FF:FF:FF:FF:FF:25。 如何解决?
答案 0 :(得分:0)
这可以使用netifaces
模块实现。
导入模块:
>>> import netifaces
获取所有存在的接口
>>> netifaces.interfaces()
['lo', 'eth0', 'tun2']
提取所选界面的Mac地址,例如。 eth0的
>>> netifaces.ifaddresses('eth0')[netifaces.AF_LINK]
[{'addr': '00:00:00:00:00:00', 'broadcast': 'ff:ff:ff:ff:ff:ff'}]