Python dictionary (Dictionary) copy () method
description
Python dictionary (Dictionary) 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/python dict1 = {'Name': 'Zara', 'Age': 7}; dict2 = dict1.copy() print "New Dictinary : %s" % str(dict2)
The above example output is:
New Dictinary : {'Age': 7, 'Name': 'Zara'}