I'm having trouble converting a list of bytes to string. Whenever I apply:
char = chr(int(byte,2))
I get the right character, but when I concatenate it with a string:
string+= char
I get weird symbols:
÷ãЪþãÝ¿HÛaû³ªI|ÁŸì½ XG„8jRTa!qÚhϹ4ý{B
After Googling, I found out that I have to convert it to UTF-8 using string.encode('utf-8')
, but after converting it, I get something like this:
b'string'
I couldn't find a way to remove the b''
from the output
string=""
for byte in bytes:
char = chr(int(byte,2))
string+=char
print(string.encode('utf-8'))
#output : b'my string'
print(string)
#output : ÷ãЪþãÝ¿HÛaû³ªI|ÁŸì½ XG„8jRTa!qÚhÏ.....
I'm looking for a way to convert my bytes to a normal string