with open(file_name, "rb") as f: bytes = f.read() encoded_file: base64 = base64.b64encode(bytes) encoded_file_utf: str = str(encoded_file, encoding='utf-8')