Is there a builtin way to "convert" a bytestring to a unicode string? I don't want to decode it, I want the string i see on print without the "b".
e.g. Input:
b'\xb5\xb5\xb5\xb5\r\n1'
output:
'\xb5\xb5\xb5\xb5\r\n1'
I've tried iterating over the byte string, but that gives me a list of integers:
my_bytestring = b'%PDF-1.4\n%\x93\x8c\x8b\x9e'
my_string = ""
my_list = []
for char in my_bytestring:
my_list.append(char)
my_string += str(char)
print(my_list) # -> list of ints
print(my_string) # -> string of converted ints
I get:
[37, 80, 68, 70, 45, 49, 46, 52, 10, 37, 147, 140, 139, 158]
I want:
['%', 'P', 'D', 'F', '-', '1', '.', '4', '\\', 'n', '%', '\\', 'x', '9', '3', '\\', 'x', '8', 'c', '\\', 'x', '8', 'b', '\\', 'x', '9', 'e']