python两个字典相加
x = {"a":1,"b":2}
2 y = {"c":3}
3 from collections import Counter
4 X,Y = Counter(x),Counter(y)
5 z = dict(X+Y)
6 print(z)
程序运行结果
{'a': 1, 'b': 2, 'c': 3}
笨鸟先飞
x = {"a":1,"b":2}
2 y = {"c":3}
3 from collections import Counter
4 X,Y = Counter(x),Counter(y)
5 z = dict(X+Y)
6 print(z)
程序运行结果
{'a': 1, 'b': 2, 'c': 3}