Friday, December 30, 2016

TypeError: Can't convert 'bytes' object to str implicitly


Error:

Traceback (most recent call last):
  File "b64-str.py", line 10, in <module>
    print('\nstring is\n' + so)
TypeError: Can't convert 'bytes' object to str implicitly


Problem Code:

so = base64.b64decode(b64)
print('\nstring is\n' + so)


Solution:

so = base64.b64decode(b64).decode('utf-8', 'ignore')
print('\nstring is\n' + so)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.