Python Forum

Full Version: printing a bytes string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
Not sure, but may be you are looking for .encode method.
x = "This is a string"
print(x.encode('utf-8'))
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.