How to use the python items() method?
Python Dictionary (Dictionary) items() method
Python Dictionary (Dictionary) items() function returns a traversable (key, value) in a list Array of tuples.
Recommended: "Python Tutorial"
Grammar
##items() method syntax:dict.items()
#!/usr/bin/python # coding=utf-8 dict = {'Google': 'www.google.com', 'Runoob': 'www.php.cn', 'taobao': 'www.taobao.com'} print "字典值 : %s" % dict.items() # 遍历字典列表 for key,values in dict.items(): print key,values
字典值 : [('Google', 'www.google.com'), ('taobao', 'www.taobao.com'), ('Runoob', 'www.php.cn')] Google www.google.com taobao www.taobao.com php www.php.cn
The above is the detailed content of How to use the python items() method. For more information, please follow other related articles on the PHP Chinese website!