Home  >  Article  >  Backend Development  >  Basic introduction to Python items() method

Basic introduction to Python items() method

Y2J
Y2JOriginal
2017-05-17 15:13:223223browse

Description

Python Dictionary (Dictionary) items() function returns a traversable array of (key, value) tuples as a list.

Syntax

items() method syntax:

dict.items()

Parameters

NA.

Return value

Returns a traversable array of (key, value) tuples.

Example

The following example shows how to use the items() function:

#!/usr/bin/pythondict = {'Name': 'Zara', 'Age': 7}
print "Value : %s" %  dict.items()

The output result of the above example is:

Value : [('Age', 7), ('Name', 'Zara')]

[Related Recommendation】

1. Special recommendation: "php Programmer Toolbox" V0.1 version download

2 . Free video tutorial on Python

3. Example of item() function in Python to traverse a dictionary

##4.

Detailed explanation of the usage of items() series functions in Python

5.

Introducing three methods of accessing dictionaries

6.

Items() method for basic introduction to Python

The above is the detailed content of Basic introduction to Python items() method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn