python 字典合并

2019-01-10  本文已影响0人  酥脆海苔饼干

python2:

dict1 = { "name":"owen", "age": 18 }
dict2 = { "birthday": "1999-11-22", "height": 180 }
print(dict(dict1.items() + dict2.items()))

python3:

dict1 = { "name":"owen", "age": 18 }
dict2 = { "birthday": "1999-11-22", "height": 180 }
print(dict(list(dict1.items()) + list(dict2.items())))
上一篇 下一篇

猜你喜欢

热点阅读