You can use Python built-in method decode to convert bytes to a string as shown in the below example –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
str1 = b"abcde" print(str1) print(type(str1)) # utf-8 is used here because it is a very common encoding, but you # need to use the encoding your data is actually in. str2 = str1.decode("utf-8") print(str2) print(type(str2)) ## Returns ## b'abcde' ## ## abcde ## |