base64.b64encode requires encoded bytes in Python 3 but it works with str in Python 2.
The result of this function is bytes in Python 3 and str in Python 2.
Encoding the data with utf-8 before passing to base64.b64encode works both for Python 2 and 3.
If the returning value is bytes (this only happens with Python 3) it needs to be decoded with utf-8
Status
READY
Description
base64.b64encode
requires encodedbytes
in Python 3 but it works withstr
in Python 2. The result of this function isbytes
in Python 3 andstr
in Python 2.Encoding the data with
utf-8
before passing tobase64.b64encode
works both for Python 2 and 3. If the returning value isbytes
(this only happens with Python 3) it needs to be decoded withutf-8