Python 字典 copy()方法 描述 Python字典方法copy()返回一个字典的浅拷贝。 语法 copy()方法的语法如下: dict.copy() PythonCopy 参数 无 返回值 此方法返回字典的浅拷贝。 示例 以下示例展示了copy()方法的使用。 dict = {'Name': 'Zara', 'Age': 7}; print "Start Len : %d" % len(dict) dict.clear() print "End Len : %d" % len(dict) PythonCopy 当我们运行以上程序时,会产生以下结果− New Dictionary : {'Age': 7, 'Name': 'Zara'} PythonCopy