PHP前端开发

Python基础入门之items()方法

百变鹏仔 3小时前 #Python
文章标签 入门

描述

python 字典(dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组。

语法

items()方法语法:

dict.items()

参数

NA。

返回值

立即学习“Python免费学习笔记(深入)”;

返回可遍历的(键, 值) 元组数组。

实例

以下实例展示了 items()函数的使用方法:

#!/usr/bin/pythondict = {'Name': 'Zara', 'Age': 7}print "Value : %s" %  dict.items()

以上实例输出结果为:

Value : [('Age', 7), ('Name', 'Zara')]