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

Basic introduction to Python items() method

Y2J
Release: 2017-05-17 15:13:22
Original
3324 people have browsed it

Description

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

Syntax

items() method syntax:

dict.items()
Copy after login

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()
Copy after login

The output result of the above example is:

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

[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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template