Home>Article>Backend Development> Python update function definition and action example analysis

Python update function definition and action example analysis

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

In this article we will learn about thepython update functionin the python dictionary. What does theupdatefunction mean in thepython dictionary? , the function of this function will be answered in the following article.

python update function description

Python dictionary (Dictionary) update() function updates the key/value pairs of dictionary dict2 into dict.

Syntax

##update() method syntax:

dict.update(dict2)

Parameters

dict2 -- Dictionary added to the specified dictionary dict.

Return value

This method does not have any return value.

Python update function example

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

#!/usr/bin/python dict = {'Name': 'Zara', 'Age': 7} dict2 = {'Sex': 'female' } dict.update(dict2) print "Value : %s" % dict

The output result of the above example is:

Value : {'Age': 7, 'Name': 'Zara', 'Sex': 'female'}

The above is All that this article talks about is the built-in update 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 tutorialcolumn on the php Chinese website.

The above is the detailed content of Python update function definition and action 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