Home > Backend Development > Python Tutorial > What can the python keys function do? Example analysis

What can the python keys function do? Example analysis

乌拉乌拉~
Release: 2018-08-18 17:54:53
Original
4842 people have browsed it

Because many people don’t know what the built-in functions in the dictionary are? what's the effect? So in this article, I will introduce the relevant knowledge about the python keys function in the python dictionary. What does the keys function mean? What is the function of this function will be discussed in the next article. get the answer.

First of all, let’s talk about what this function can do?

keys function

Python Dictionary (Dictionary) keys() function returns all the keys of a dictionary as a list.

Syntax

keys() method syntax:

dict.keys()
Copy after login

Parameters

##NA.

Return value

Returns all the keys of a dictionary.

keys function example

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

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7}

print "Value : %s" %  dict.keys()
Copy after login

The output result of the above example is as follows:

Value : ['Age', 'Name']
Copy after login
The above is all the content of this article, the built-in keys function of the dictionary in Python. I hope what I said and the examples I gave can be helpful to you.

For more related knowledge, please visit the

Python tutorial column on the php Chinese website.

The above is the detailed content of What can the python keys function do? Example analysis. 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