Python3 dictionary update () method
description
Python dictionary update () function to the dictionary dict2 key / value pairs in the update to the dict.
grammar
update () method syntax:
dict.update(dict2)
parameter
- dict2 - added to the dictionary dict specified in the dictionary.
return value
This method has no return value.
Examples
The following example shows the update () method using the function:
#!/usr/bin/python3 dict = {'Name': 'w3big', 'Age': 7} dict2 = {'Sex': 'female' } dict.update(dict2) print ("更新字典 dict : ", dict)
The above example output is:
更新字典 dict : {'Sex': 'female', 'Age': 7, 'Name': 'w3big'}