您应该使用
argtypes和
restype成员在Python中设置函数的参数类型和返回类型:
test.eval.argtypes = [ctypes.POINTER(ctypes.c_double),ctypes.c_int,ctypes.POINTER(ctypes.c_double),ctypes.c_int,ctypes.c_int]test.eval.restype = ctypes.c_double
然后,您可以像执行此操作一样调用它:构造
(ctypes.c_double *length)用您的值初始化的类型的数组,并且
result将为
double。
另请参阅本ctypes教程,它具有许多有用的信息。



