Python 3

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

Python 2

z = dict(x, **y)

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

相关文章: