If you need to convert a Bytearray to a String in Python, then you can do the following:
Option 1 – Using bytes()
1
2
3
|
b = bytearray("test", encoding="utf-8")
str1 = bytes(b)
print(str1)
|
Option 2 – Using bytearray.decode()
1
2
3
|
b = bytearray("test", encoding="utf-8")
str1 = b.decode()
print(str1)
|