我正在使用ctypes
与用C编写的DLL接口,我创建了一个数组:
foo = (c_double * 1000)()
bar = (c_double * 1000)()
我可以使用foo[:]
获取所有值,类型为:
type(foo)
c_double_array_1000
但是我不能用bar减去foo:
unsupported operand type(s) for -: 'c_double_Array_1000' and 'c_double_Array_1000'
我错过了什么?
答案 0 :(得分:0)
import ctypes
foo = (ctypes.c_double * 3)(14, 22, 37)
bar = (ctypes.c_double * 3)(0, 1, 2)
diff = [foo[i]-bar[i] for i in range(len(foo))]
print diff
答案 1 :(得分:0)