Python 字典(Dictionary) items()方法

2021-09-06 14:24 更新

Python 字典(Dictionary) items()方法


描述

Python 字典(Dictionary) items() 函數(shù)以列表返回可遍歷的(鍵, 值) 元組數(shù)組。

語法

items()方法語法:

dict.items()

參數(shù)

  • NA。

返回值

返回可遍歷的(鍵, 值) 元組數(shù)組。

實例

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

#!/usr/bin/python

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

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

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

Value : [('Age', 7), ('Name', 'Zara')]
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號