将python int转换为int16_t类型

时间:2016-02-24 23:15:32

标签: python c python-2.7 types type-conversion

我知道可以使用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.

1 个答案:

答案 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