python语法中, items用于字典, 作用是以列表返回可遍历的(key, value)的元组数组
1. 语法
1 dict.items()
2. 实例
(1) 代码
1 #!/usr/bin/env python 2 # coding=utf-8 3 4 dict_a = { 5 (1, 2, 3) : "helloworld", 6 "baidu" : "www.baidu.com", 7 "we are young" : "YES!" 8 } 9 10 for key, value in dict_a.items(): 11 print str(key) + "=" + str(value)
(2) 结果
baidu=www.baidu.com
we are young=YES!
(1, 2, 3)=helloworld