【发布时间】:2014-10-26 13:36:25
【问题描述】:
我正在尝试获取图像,然后将其转换为 Python 可以理解的对象,然后上传。
这是我尝试过的:
# Read the image using .count to get binary
image_binary = requests.get(
"http://danealva143.files.wordpress.com/2014/03/2012-08-girls-920-26.jpg").content
string_buffer = io.BytesIO()
string_buffer.write(image_binary)
string_buffer.seek(0)
files = {}
files['image'] = Image.open(string_buffer)
payload = {}
results = requests.patch(url="http://127.0.0.1:8000/api/profile/94/", data=payload, files=files)
我收到此错误:
File "/Users/user/Documents/workspace/test/django-env/lib/python2.7/site-packages/PIL/Image.py", line 605, in __getattr__
raise AttributeError(name)
AttributeError: read
为什么?
【问题讨论】:
标签: python python-2.7 python-imaging-library python-requests