+ 3

How to encode and decode a string in python?

i use this code but I got error. x='Hello man' y=x.encode('base64','strict') print(y) error= 'base64' is not a text encoding; use codecs.encode() to handle arbitrary codecs.

4th Sep 2018, 4:28 PM
Maninder $ingh
Maninder $ingh - avatar
1 ответ
+ 5
In Python3, if you want base64 import base64, use b64encode(). (Note, b64encode expects bytestrings) bytestrings: bytes("string", "ascii") "string".encode() b"string" bytestring -> normal: b"string".decode() ...
4th Sep 2018, 4:54 PM
Kirk Schafer
Kirk Schafer - avatar