Convert bytes to a string

Decode the bytes object to produce a string:

>>> b"abcde".decode("utf-8") 
'abcde'

The above example assumes that the bytes object is in UTF-8, because it is a common encoding. However, you should use the encoding your data is actually in!

Leave a Comment