简体   繁体   中英

python make string from c_char list

How can i make string from a list which contains c_char types.

so for example the C code:

static const char data [] = {0x45, 'b', 'a'}

you can send it on socket.

I would like to do this in python. Is it possible? that is important, 1 element 1 byte.

You can use the python type bytearray to store your values and then send it directly over the socket:

Sending binary data over sockets with Python

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