我知道可以使用ctypes将python int转换为c int类型 但是如何将python int转换为int16_t类型?
我试过了:
import ctypes as ct
my_c_number = ct.c_int16_t(1)
#Apparently ctypes library does not have c_int16_t attribute.
答案 0 :(得分:0)
ctypes.c_int16
怎么样?如果您正在寻找,也支持ctypes.c_uint16
。
文档:
https://docs.python.org/2/library/ctypes.html#ctypes.c_int16和
https://docs.python.org/2/library/ctypes.html#ctypes.c_uint16