Python dictionary items() 方法
搞懂Python dictionary items() 方法的用法
描述
Python 字典 items() 方法以列表返回可遍历的(键, 值) 元组数组。
语法
items()方法语法:
参数
NA。
返回值
返回可遍历的(键, 值) 元组数组。
实例
以下实例展示了 items() 方法的使用方法:
dict = {'Name' : 'Lidihuo' , 'Age' : 2}
print( "Value : %s " % dict.items ())
以上实例输出结果为:
Value : dict_items([('Name', 'Lidihuo'), ('Age', 2)])