Python update function definition and action example analysis

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

In this article we will learn about the python update function in the python dictionary. What does the update function mean in the python 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)
Copy after login

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

The output result of the above example is:

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

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 tutorial column 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!

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