Python3 字典
描述
Python 字典 copy() 函數(shù)返回一個(gè)字典的淺復(fù)制。
語(yǔ)法
copy()方法語(yǔ)法:
dict.copy()
參數(shù)
- NA。
返回值
返回一個(gè)字典的淺復(fù)制。
實(shí)例
以下實(shí)例展示了 copy()函數(shù)的使用方法:
#!/usr/bin/python3
dict1 = {'Name': 'W3CSchool', 'Age': 7, 'Class': 'First'}
dict2 = dict1.copy()
print ("新復(fù)制的字典為 : ",dict2)
以上實(shí)例輸出結(jié)果為:
新復(fù)制的字典為 : {'Name': 'W3CSchool', 'Age': 7, 'Class': 'First'}
更多建議: