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

What can the python keys function do? Example analysis

乌拉乌拉~
乌拉乌拉~Original
2018-08-18 17:54:534779browse

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()

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()

The output result of the above example is as follows:

Value : ['Age', 'Name']

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!

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

Related articles

See more