标签:cad lis python ddr val class 代码 value lang
列表如下
[
{‘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 列表 ]
python列表里面有多个字典,怎么取出每个字典特定key的value组成列表?
标签:cad lis python ddr val class 代码 value lang
原文地址:https://www.cnblogs.com/ludundun/p/14607121.html