列表如下
[
{'name': 'eth0', 'macAddr': '2c:44:fd:7f:56:a4'},
{'name': 'eth5', 'macAddr': 'd8:9d:67:f2:ef:74'},
{'name': 'eth3', 'macAddr': '2c:44:fd:7f:56:a7'},
{'name': 'eth1', 'macAddr': '2c:44:fd:7f:56:a5'},
{'name': 'eth4', 'macAddr': 'd8:9d:67:f2:ef:70'},
{'name': 'eth2', 'macAddr': '2c:44:fd:7f:56:a6'}
]
取出每个列表key为macAddr的对应value,组成列表,例如这种
["2c:44:fd:7f:56:a4","d8:9d:67:f2:ef:74".......]
代码:
lis = [ i['macAddr'] for i in 列表 ]