如何通过 python 在 windows 获得多个 eternet mac 地址?

How to get several eternet mac address by python at windows?

我正在尝试通过 python 获取多个 eternet mac 地址。
我尝试了这个 python 代码,它可以获取第一个 mac 地址。

import getmac
print(getmac.get_mac_address())

在我的电脑上,我安装了Virtual Box,它安装了2个虚拟永恒适配器。我想获取所有 mac 地址列表,其中包括带有 Python.

的 Virtual Box(或 Hyper-V)mac 地址

我正在使用 Windows10 x64。
此致 Ryan。

使用netifaces:

import netifaces
iface = netifaces.ifaddresses('YOUR NETWORK INTERFACE NAME')[netifaces.AF_LINK]
print(iface['addr'])
import netifaces
for nic in netifaces.interfaces():
    iface = netifaces.ifaddresses(nic)[netifaces.AF_LINK]
    if len(iface[0]['addr']) > 0:
        print("mac address: ", iface[0]['addr'])

谢谢阿西夫·哈桑。