python 字典的一些操作
python实现两个字典合并
方法一:借助dict(d1.items() + d2.items())的方法
1 a={"a":1,"b":2,"c":3} 2 b= {"aa":11,"bb":22,"cc":33} 3 dict(a.items()+b.items()) 4 # 结果: 5 {"a": 1, "aa": 11, "c": 3, "b": 2, "bb": 22, "cc": 33}
1 a={"a":1,"b":2,"c":3} 2 b= {"aa":11,"bb":22,"cc":33} 3 dict(a.items()+b.items()) 4 # 结果: 5 {"a": 1, "aa": 11, "c": 3, "b": 2, "bb": 22, "cc": 33}