📜  python 将 dict 列表合并为单个 dict - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:47.529000             🧑  作者: Mango

代码示例3
l = [{'a': 0}, {'b': 1}, {'c': 2}, {'d': 3}, {'e': 4, 'a': 4}]
d = {k: v for x in l for k, v in x.items()}
print(d)
# {'a': 4, 'b': 1, 'c': 2, 'd': 3, 'e': 4}