In this example, you will learn to convert bytes to a string.
To understand this example, you should have the knowledge of the following Python programming topics:
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 ✅.
Related posts:
Python String zfill()
Python Program to Catch Multiple Exceptions in One Line
Python Program to Display the multiplication Table
Debug a JavaMail Program
Python delattr()
Python Program to Add Two Matrices
Python String rjust()
Python super()
Python sleep()
Python repr()
Python hex()
Python globals()
Python all()
Python Dictionary
Python Program to Sort a Dictionary by Value
Python String casefold()
Python bytes()
Python Program to Check If a List is Empty
Python Set difference()
Python Program to Find ASCII Value of Character
Python Program to Print Output Without a Newline
Python Object Oriented Programming
Python String find()
Python set()
Python list()
Python Function Arguments
Python Program to Count the Number of Digits Present In a Number
Python strftime()
Python String isprintable()
Python for Loop
Python Program to Copy a File
Python String lstrip()