Python 字典(Dictionary) items()方法
2017-10-10 14:14
489 查看
描述
Python 字典(Dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组。
语法
items()方法语法:dict.items()
参数
NA。
返回值
返回可遍历的(键, 值) 元组数组。
实例
以下实例展示了 items()函数的使用方法:
实例(Python 2.0+)
#!/usr/bin/python#coding=utf-8
dict = {'Google':
'www.google.com',
'Runoob':
'www.runoob.com',
'taobao':
'www.taobao.com'}
"字典值 : %s"
% dict.items()
# 遍历字典列表for
key,values
in
dict.items():
key,values
以上实例输出结果为:
字典值 : [('Google', 'www.google.com'), ('taobao', 'www.taobao.com'), ('Runoob', 'www.runoob.com')] Google www.google.com taobao www.taobao.com Runoob www.runoob.com
相关文章推荐
- python字典(dictionary)中get和items、iteritems方法
- 1006- Python 字典(Dictionary) items()方法
- Python 字典(Dictionary) setdefault()方法
- Python 字典(Dictionary) setdefault()方法
- Python中字典的items()方法
- Python中使用items()方法返回字典元素对的教程
- 【Python】Python中字典的items(), keys(), values()方法
- Python 字典(Dictionary) get()方法
- Python 字典 items() 方法
- Python 字典(Dictionary) setdefault()方法
- Python 字典(Dictionary) has_key()方法
- Python 字典(Dictionary) keys()方法
- Python 字典(Dictionary) get()方法
- Python 字典(Dictionary) values()方与 keys()方法
- Python中使用items()方法返回字典元素对的教程
- Python 字典(Dictionary) update()方法
- Python 字典(Dictionary) get()方法
- Python 字典(Dictionary) update()方法
- Python 字典(Dictionary) get()方法
- Python 字典(Dictionary) setdefault()方法