# utf-8 is used here because it is a very common encoding, but you # need to use the encoding your data is actually in. bytes = b'abcde' bytes.decode("utf-8") 'abcde'
Here is what the above code is Doing:
1. The bytes object is created by passing a string to the b prefix.
2. The bytes object is passed to the decode() method.
3. The decode() method returns a string.
The decode() method takes an encoding argument. This argument is
required. If you don’t pass an encoding, you’ll get an error.
The encoding argument tells the decode() method what encoding to use.
If you don’t know what encoding to use, you can try utf-8. utf-8 is a
very common encoding, but it’s not the only one.
If you try to decode data with the wrong encoding, you’ll get an error.