小编Kyl*_*aro的帖子

Python按键删除列表中的字典

考虑以下代码:

some_list = [
    {'id' : '3459', 'name' : 'Alice'},
    {'id' : '1112', 'name': 'Bob'}
]
person_id = '3459'
# Search person id in list of dictionaries and return {'id' : '3459', 'name' : 'Alice'}
Run Code Online (Sandbox Code Playgroud)

知道了person_id,是有可能搜索这个some_list'id'抢整部字典?目前,我正在使用for循环执行此操作,但我想知道是否还有其他实现。感谢所有答复。

python dictionary list python-3.x

2
推荐指数
1
解决办法
81
查看次数

标签 统计

dictionary ×1

list ×1

python ×1

python-3.x ×1