对于嵌套字典,不要使用dict(srcData) or srcData.copy() or {**srcData},因为如果您更改第二级或更多,它也会修改源字典
srcData = {'first': {'second': 'second Value'}}newData = dict(srcData) # srcData.copy() or {**srcData}newData['first']['second'] = 'new Second Value'
print(srcData)print(newData)
# it will print# srcData: {'first': {'second': 'new Second Value'}}# newData:{'first': {'second': 'new Second Value'}}
# but it should be# srcData: {'first': {'second': 'second Value'}}# newData:{'first': {'second': 'new Second Value'}}