37,742
社区成员
发帖
与我相关
我的任务
分享

l = [ i['macAddr'] for i in 列表 ]
all_adapter=[{'name': 'eth0', 'description': 'Broadcom Inc. and subsidiaries NetXtreme BCM5719 Gigabit Ethernet PCIe', 'status': '1', 'macAddr': '2c:44:fd:7f:56:a4'}, \
{'name': 'eth5', 'description': 'Emulex Corporation OneConnect 10Gb NIC (be3)', 'status': '0', 'macAddr': 'd8:9d:67:f2:ef:74'}, \
{'name': 'eth3', 'description': 'Broadcom Inc. and subsidiaries NetXtreme BCM5719 Gigabit Ethernet PCIe', 'status': '1', 'macAddr': '2c:44:fd:7f:56:a7'}, \
{'name': 'eth1', 'description': 'Broadcom Inc. and subsidiaries NetXtreme BCM5719 Gigabit Ethernet PCIe', 'status': '1', 'macAddr': '2c:44:fd:7f:56:a5'}, \
{'name': 'eth4', 'description': 'Emulex Corporation OneConnect 10Gb NIC (be3)', 'status': '0', 'macAddr': 'd8:9d:67:f2:ef:70'}, \
{'name': 'eth2', 'description': 'Broadcom Inc. and subsidiaries NetXtreme BCM5719 Gigabit Ethernet PCIe', 'status': '0', 'macAddr': '2c:44:fd:7f:56:a6'}]
macAddrList=[]
for net_adapter_dict in all_adapter:
macAddrList.append(net_adapter_dict['macAddr'])
print(macAddrList)