Python3 dictionary copy () method
description
Python dictionaries copy () function returns a shallow copy of the dictionary.
grammar
copy () method syntax:
dict.copy()
parameter
- NA.
return value
Returns a shallow copy of a dictionary.
Examples
The following examples show the copy () function to use:
#!/usr/bin/python3 dict1 = {'Name': 'w3big', 'Age': 7, 'Class': 'First'} dict2 = dict1.copy() print ("新复制的字典为 : ",dict2)
The above example output is:
新复制的字典为 : {'Age': 7, 'Name': 'w3big', 'Class': 'First'}