Created by Aaron MaenpaaLinked to 8.4m issues across 200 teams
To convert a bytes
object to a string, you need to decode it using the correct encoding. The most common encoding is UTF-8, but you should use the encoding your data is actually in. To decode a bytes
object, use the decode()
method. For example, if you have a bytes
object called b"abcde"
, you can decode it to a string like this:
b"abcde".decode("utf-8")
This will return the string 'abcde'
.