Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python键错误,即使存在字典键_Python - Fatal编程技术网

Python键错误,即使存在字典键

Python键错误,即使存在字典键,python,Python,在尝试访问ret_dict['mesh_triangles\u center']时,以下内容导致一个键错误: mtc_arr = [] mfn_arr = [] ... ret_dict['mesh_triangles_center'] = np.stack(mtc_arr, axis=0) ret_dict['mesh_face_normals'] = np.stack(mfn_arr, axis=0) 我不知道为什么。这似乎与原始mtc_arr易变性

在尝试访问ret_dict['mesh_triangles\u center']时,以下内容导致一个键错误:

    mtc_arr = []
    mfn_arr = []
    ...
    ret_dict['mesh_triangles_center'] = np.stack(mtc_arr, axis=0)
    ret_dict['mesh_face_normals'] = np.stack(mfn_arr, axis=0)

我不知道为什么。这似乎与原始mtc_arr易变性有关。

使用deepcopy修复了它:

    ret_dict['mesh_triangles_center'] = copy.deepcopy(np.stack(mtc_arr, axis=0))
    ret_dict['mesh_face_normals'] = copy.deepcopy(np.stack(mfn_arr, axis=0))