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}

posted @ 2020-10-14 19:11  zou-ting-rong  阅读(1632)  评论(0编辑  收藏  举报