Python 3.x 无法将ctypes结构分配给numpy数组

Python 3.x 无法将ctypes结构分配给numpy数组,python-3.x,ctypes,Python 3.x,Ctypes,我正在尝试将自定义ctypes.Structure分配到numpy数组中,如下所示: 将numpy导入为np 导入ctypes 类结构(ctypes.Structure): _字段=[ (“x”,ctypes.c_int32), (“y”,ctypes.c_int32), ] 数组=np.zeros((2,),数据类型=Struct) 数组[0]=Struct(2,2) 但我收到了错误信息: array[0] = Struct(2, 2) ValueError: invalid lit

我正在尝试将自定义
ctypes.Structure
分配到numpy数组中,如下所示:

将numpy导入为np
导入ctypes
类结构(ctypes.Structure):
_字段=[
(“x”,ctypes.c_int32),
(“y”,ctypes.c_int32),
]
数组=np.zeros((2,),数据类型=Struct)
数组[0]=Struct(2,2)
但我收到了错误信息:

    array[0] = Struct(2, 2)
ValueError: invalid literal for int() with base 10: b'\x02\x00\x00\x00\x02\x00\x00\x00'
是否仍然可以将ctypes结构分配给numpy数组