In this article, let’s learn about the python items function in the python dictionary. What does the items function mean? What effect does this function have? Get the answer in the following article.
Description
Python Dictionary (Dictionary) items() function returns a traversable array of (key, value) tuples as a list.
Syntax
items() method syntax:
dict.items()
Parameters
Return value
Returns a traversable array of (key, value) tuples.Example
The following example shows how to use the items() function:# !/usr/bin/python # coding=utf-8 dict = {'Google': 'www.google.com', 'Runoob': 'www.runoob.com', '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.runoob.com')] Google www.google.com taobao www.taobao.com Runoob www.runoob.com
Python tutorial column on the php Chinese website.
The above is the detailed content of What is the python items function? How to use it?. For more information, please follow other related articles on the PHP Chinese website!