简体   繁体   中英

Convert python int into int16_t type

I know that python int can be converted into an c int type using ctypes.
But how do I convert a python int into an int16_t type?

I have tried:

import ctypes as ct
my_c_number = ct.c_int16_t(1)
#Apparently ctypes library does not have c_int16_t attribute.

How about ctypes.c_int16 ? Also supports ctypes.c_uint16 if you are looking for that.

Documentation:
https://docs.python.org/2/library/ctypes.html#ctypes.c_int16 and
https://docs.python.org/2/library/ctypes.html#ctypes.c_uint16

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM