[英]How to force NumPy to always use a precision (float32, float64 …)?
[英]python comtypes how to pass numpy float32 (singe-precision float) as scalar?
根据comtypes文档,可以将numpy数组传递给comtypes对象,但是如何传递标量值,例如numpy.float32(1.0)
?
https://pythonhosted.org/comtypes/#numpy-interop
我收到以下错误:
---------------------------------------------------------------------------
ArgumentError Traceback (most recent call last)
<ipython-input-67-9e7e5859c6a5> in <module>()
----> 1 com_obj.Update("string_name",np.float32(6.6e-6))
ArgumentError: argument 2: <type 'exceptions.TypeError'>: Cannot put 6.5999998e-06 in VARIANT
传递ctypes.c_float
而不是np.float32
将起作用。 例如com_obj.Update("string_name", ctypes.c_float(6.6e-6))
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.