Convert Bytes to String in Python

Last modified: 2023-08-29

Cryptography

We can decode bytes to string in Python.

Conversion

Using decode method in Python, we can easily convert bytes to string.
There are three types of decode methods as below.

All of the results say "Hello".

b'Hello'.decode('utf-8')

bytes.decode(b'Hello', 'utf-8')

codecs.decode(b'Hello', 'utf-8')