【发布时间】:2015-04-07 10:33:15
【问题描述】:
当我从服务器获取二进制文件时,我通过r.content 访问它。问题是我想将此二进制文件转换为图像,然后将其发送到浏览器,如下所示:
i = Image.open(StringIO(r.content))
但是调用它会返回以下错误:
AttributeError('JpegImageFile instance has no __call__ method',)
或者例如:
AttributeError('PngImageFile instance has no __call__ method',)
此代码来自python documentation
【问题讨论】:
-
你能展示你剩下的代码吗?你是如何阅读图像的?并存储它?听起来问题很可能是因为您的图像名称,也许它与您代码中的其他对象冲突!
-
不确定您的具体问题,但您是否考虑过将图像下载到临时文件然后打开它?
-
存储服务器在别处。我只是通过
requests.postKasraAD、@SeanAzlin 上传到该存储服务器
标签: python binary python-requests stringio