Skip to content

How to Convert Bytearray to String in Python

If you need to convert a Bytearray to a String in Python, then you can do the following:

Option 1 – Using bytes()

b = bytearray("test", encoding="utf-8") str1 = bytes(b) print(str1)
Code language: Python (python)

Option 2 – Using bytearray.decode()

b = bytearray("test", encoding="utf-8") str1 = b.decode() print(str1)
Code language: Python (python)

See also  How to Find the Area or Perimeter of a 4-sided Polygon using Java
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x