You need to decode the bytes object to produce a string:
>>> b"abcde"
b'abcde'
# utf-8 is used here because it is a very common encoding, but you
# need to use the encoding your data is actually in.
>>> b"abcde".decode("utf-8")
'abcde'
How do I convert the bytes value back to string? I mean, using the "batteries" instead of doing it manually. And I'd like it to be OK with Python 3.
In Python 3.x, those implicit conversions are gone - conversions between 8-bit binary data and Unicode text must be explicit, and bytes and string objects ...
2017年7月11日 ... Python 3最重要的新特性之一是对字符串和二进制数据流做了明确的区分。文本总是Unicode,由str类型表示,二进制数据则由bytes类型表示。Python 3不会 ...
So, What About Unicode on Python 3? · str corresponds to the former unicode type on Python 2. It is represented internally as a sequence of Unicode codepoints.
Python 3 : Convert string to bytes. author image. By mkyong | Last updated: September 3, 2015. Viewed: 230,892 (+170 pv/w). Tags:python.
convert bytes to string in Python convert string to bytes in Python , We can convert bytes to String using bytes class decode() instance method, ...