Python如何合并两个字典

Python 3

x = {'a': 1, 'b': 2}
y = {'b': 3, 'c': 4}
z = {**x, **y}

Python 2

z = dict(x, **y)

Python中只能处理这种简单的合并,如果出现相同的key,Python会选择覆盖

原文地址:https://www.cnblogs.com/daryl-blog/p/11003053.html