列表推导式
data = [{"key": "value", "name": "Alice", "age": 30},{"key": "other_value", "name": "Bob", "age": 25},{"key": "value", "name": "Charlie", "age": 35},{"key": "another_value", "name": "David", "age": 40}
]matching_dicts = [item for item in data if item.get("target_key") == target_value]
遍历循环
for item in data:if ttem.get("target_key") == target_value:matching_dicts.append(item)