我有一个C SDK返回的图像缓冲区
我可以写入本地图像并将其作为base64
字符串读取,但这需要额外的步骤。你知道吗
如何将字节数组直接转换为base64字符串,以便在网络请求中发送它?你知道吗
image = (ctypes.c_ubyte*s.dwDataLen)()
ctypes.memmove(image, s.pBuffer, s.dwDataLen)
我尝试使用base64.encodestring
,但出现了这个错误
TypeError: expected single byte elements, not '<B' from c_ubyte_Array_8716
试试这个:
如果您正在使用
base64.b64encode
,您应该能够将image
传递给它:您可以使用
base64
模块这种情况与Encoding an image file with base64类似
相关问题 更多 >
编程相关推荐