/  Technology   /  Python Convert bytes to String
Python Convert bytes to String

Python Convert bytes to String

This article will guide you on how to convert bytes to string

 

Example 1:

 

s = b'abc'
print(type(s))

# bytes to string using decode()
s = b.decode()
print('After decoding to string =', s)
print(type(s))

 

Output:

 

Python Convert bytes to String

 

Example 2:

 

You can also decode in the below manner.

 

b'xyz'.decode()

 

Output:

 

Python Convert bytes to String

 

Leave a comment