yuanyuan2017

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])
 

分类:

技术点:

相关文章: