Jul-10-2021, 05:15 PM
Jul-10-2021, 06:33 PM
Here is the example of the tuple below :
Obs : I need the data type to be in bytes.
# define tuple for http header t_header = ( "Content-type: image/png \r", "Content-Language: pt-BR \r", ) b_header = bytearray(t_header, 'utf-8') print(type(b_header))Error msg : TypeError: encoding without a string argument ?
Obs : I need the data type to be in bytes.
Jul-10-2021, 06:40 PM
t_header = ( "Content-type: image/png \r", "Content-Language: pt-BR \r", ) b_header = bytearray(str(t_header), 'utf-8') print(type(b_header))
Output:<class 'bytearray'>
Jul-10-2021, 08:48 PM
Seems like a really odd thing to do. I would understand converting a string to byte array. What makes you think you need a tuple? As far as I know, tuples don't exist outside of Python.