美文网首页
python 字典合并

python 字典合并

作者: 酥脆海苔饼干 | 来源:发表于2019-01-10 14:17 被阅读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())))

相关文章

网友评论

      本文标题:python 字典合并

      本文链接:https://www.haomeiwen.com/subject/xnharqtx.html