'Python: encoding without a string argument

I have a data encoded like:

data = base64.b64encode(bytes(responce, 'utf-8'))

But I don't know how to decode this type of data? First I tried to use

decoded_data = base64.b64decode(data)

but this produced the following error:

"binascii.Error: Incorrect padding"

Afterwards, I tried

decoded_data = base64.b64decode(bytes(data,'utf-8'))

and got a different error:

"encoding without a string argument"

And finally I tried

decoded_data = base64.decodebytes(data)

but also got an error:

"binascii.Error: Incorrect padding".

How can I decode this data?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source