69pao国产精品视频-久久精品一区二区二三区-精品国产精品亚洲一本大道-99国产综合一区久久

Python 字典 Dictionary update()方法

Python 字典 Dictionary update()方法

Python 字典 DictionaryPython 字典 Dictionary

Python 字典(Dictionary) update() 函數(shù)把字典dict2的鍵/值對更新到dict里。

 

語法

update()方法語法:

dict.update(dict2)

 

參數(shù)

  • dict2 -- 添加到指定字典dict里的字典。

 

返回值

該方法沒有任何返回值。

 

實例

以下實例展示了 update()函數(shù)的使用方法:

 

實例

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7}
dict2 = {'Sex': 'female' }

dict.update(dict2)
print "Value : %s" %  dict    

以上實例輸出結果為:

Value : {'Age': 7, 'Name': 'Zara', 'Sex': 'female'}

Python 字典 DictionaryPython 字典 Dictionary

下一節(jié):Python 字典(Dictionary) values()方法

Python 教程

相關文章