博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
update()
阅读量:4680 次
发布时间:2019-06-09

本文共 260 字,大约阅读时间需要 1 分钟。

如下,update() 用于把字典 dict2 的键/值对更新到 dict1 里,相当于追加字典

In [13]: dict1 = {
"a":1, "b": 2}In [14]: dict2 = {
"c":3, "d": 4}In [15]: dict1.update(dict2)In [16]: dict1Out[16]: {
'a': 1, 'b': 2, 'c': 3, 'd': 4}

 

 

 

 

 

    

转载于:https://www.cnblogs.com/pzk7788/p/10247839.html

你可能感兴趣的文章