📜  pythom sum - Python 代码示例

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

代码示例1
from collections import Counter

x = {'both1':1, 'both2':2, 'only_x': 100 }
y = {'both1':10, 'both2': 20, 'only_y':200 }

z = dict(Counter(x)+Counter(y))

print(z)
[out]:
{'both2': 22, 'only_x': 100, 'both1': 11, 'only_y': 200}