Is there any way to remove the b'' from decoded base64 output?

When i run

import base64

hook = base64.b64decode(a)


It returns:


But i want it to only return not the b”. Is there anyway to fix the problem? I know it says it because the type is byte.

>Solution :

That’s a bytes value that should be decoded to a str value:

>>> print(hook.decode())

Base64 is usually used to encode arbitrary binary data as ASCII text, which is why b64decode returns a bytes value. In this case, though, the "binary" data is itself just ASCII-encoded (or possibly UTF-8-encoded) text.

Leave a Reply