【每天进步一点点 Python 】Python 字典(Dictionary) items()方法 用法

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

 

dict = {'Google': 'www.google.com', 'Runoob': 'www.runoob.com', 'taobao': 'www.taobao.com'}

print "字典值 : %s" % dict.items()

结果:

[('Google', 'www.google.com'), ('taobao', 'www.taobao.com'), ('Runoob', 'www.runoob.com')]
为什么写在微博上呢? 因为看源码,经常遇到,每次遇到都理解不清楚

测试
print(parameter.items())

 

print(list(parameter.items()))
print(list(parameter.items())[0])
 
posted @ 2018-10-19 17:28  初学者,方圆几里  阅读(487)  评论(0编辑  收藏  举报