Python base64.b64decode()

Decode a Base64 encoded string


base64.b64decode(s[, altchars])


s - is the string to decode.
Optional altchars must be a string of at least length 2 (additional characters are ignored) which specifies the alternative alphabet used instead of the + and / characters.

Return value

The decoded string is returned. A TypeError is raised if s were incorrectly padded or if there are non-alphabet characters present in the string.


<<< import base64
<<< encoded = 'YmFzZTY0IGVuY29kZWQgc3RyaW5n'
<<< data = base64.b64decode(encoded)
<<< data
'base64 encoded string'


See also: