【发布时间】:2018-04-02 09:34:59
【问题描述】:
我正在从包含 png 文件的数据库中读取 blob。
blob 看起来正确并且是字节数据类型。它开始了:
b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x92\x00\x00\x00m\x08\x06\x00\x00\x00J\xbf8B\x00\x00\x00\x06bKGD\x00\x00\x00\x00\x00\x00\xf9C\xbb\x7f\x00\x00\x00\tpHYs\x00\x00\x0b\x13\x00\x00\
但是,当我执行时:
image = wx.Image(blob)
我收到消息:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
似乎将字节视为字符串,但为什么呢?
【问题讨论】:
-
糟糕,这是
wx.Image()。 -
您能否向我们指出您正在使用的
wx.Image()的文档?我似乎找不到带缓冲区的构造函数in the documentation I've found -
我没有看到任何使用原始字节的构造函数:wxpython.org/Phoenix/docs/html/wx.Image.html#api-class-api
标签: python image python-3.x wxpython