0
当我从服务器获取二进制文件时,我通过r.content
访问它。问题是,我想这个二进制转向图像,然后将其发送给浏览器,如下:JpegImageFile实例没有StringIO的__call__方法
i = Image.open(StringIO(r.content))
但调用将返回以下错误:
AttributeError('JpegImageFile instance has no __call__ method',)
,或者例如:
AttributeError('PngImageFile instance has no __call__ method',)
此代码是从python documentation
你能告诉你的代码的其余部分?你如何阅读图像?并存储?很可能听起来问题是因为你的图像名称,或许它与你的代码中的其他对象发生冲突! – Kasramvd 2015-02-07 08:58:22
不确定您的具体问题,但您是否考虑过将图像下载到临时文件然后打开它? – 2015-02-07 08:59:55
存储服务器在别的地方。我只需通过'requests.post' @KasraAD,@SeanAzlin上传到那个存储服务器 – ALH 2015-02-07 09:30:31