Python 字典 Dictionary keys()方法

Python 字典 Dictionary keys()方法

Python 字典 DictionaryPython 字典 Dictionary

Python 字典(Dictionary) keys() 函數(shù)以列表返回一個(gè)字典所有的鍵。

 

語法

keys()方法語法:

dict.keys()

 

參數(shù)

  • NA。

 

返回值

返回一個(gè)字典所有的鍵。

 

實(shí)例

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

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7}

print "Value : %s" %  dict.keys()

以上實(shí)例輸出結(jié)果為:

Value : ['Age', 'Name']

Python 字典 DictionaryPython 字典 Dictionary

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

Python 教程

相關(guān)文章
亚洲国产精品第一区二区,久久免费视频77,99V久久综合狠狠综合久久,国产免费久久九九免费视频