【发布时间】:2018-05-19 23:49:54
【问题描述】:
from PIL import Image
from bson import Binary
img = Image.open('test.jpg')
img = Binary(img)
抛出一个错误声明TypeError : data must be an instance of bytes
为什么会这样?以及如何解决这个问题以将 img 存储到 MongoDB?
【问题讨论】:
-
您可以查看以下答案:stackoverflow.com/a/11916520/7677986
-
@MoiSyme 试过了。不工作。抛出 TypeError。
标签: mongodb python-3.x opencv binary pymongo