Python Forum
printing a bytes string - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: printing a bytes string (/thread-19937.html)



printing a bytes string - Skaperen - Jul-20-2019

is there a quick and simple (one statement or one function/method call) to print a byte string (to stdout) without including the b' part?


RE: printing a bytes string - scidam - Jul-21-2019

Not sure, but may be you are looking for .encode method.
x = "This is a string"
print(x.encode('utf-8'))



RE: printing a bytes string - Skaperen - Jul-21-2019

actually, i think i am looking for .decode() since what i have to be printed is a bytearray (several of them). i'm thinking i need to make a printb() function to do it.