Python3 dictionary.items()方法

items() 方法返回字典(鍵,值)元組對列表。

語法

以下是 items() 語法方法 -
dict.items()

參數

  • NA

返回值

此方法返回元組對的列表。

示例

下麵的示例演示items() 方法的使用。
#!/usr/bin/python

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

print ("Value : %s" %  dict.items())
當我們運行上面的程式,會產生以下結果 -
Value : [('Age', 7), ('Name', 'Zara')]

上一篇: Python3元組 下一篇: Python3字典