Categories
Python Examples

Python Program to Convert Bytes to a String


In this example, you will learn to convert bytes to a string.

Using decode()

print(b'Easy \xE2\x9C\x85'.decode("utf-8"))

Output

Easy ✅

Using decode(), you can convert bytes into string. Here, we have used utf-8 for decoding. \xE2\x9C\x85 is the utf-8 code for ✅.


You can learn about encoding on Python String encode().


Source

Leave a Reply

Your email address will not be published. Required fields are marked *