how to set encoding to base64 while writing a file in python code example Example: decode base64 python import base64 msg = base64.b64decode(msg)