0
我正尝试将图像上传到Face.com API。它要么为图像提供url,要么可以直接上传图像。 Their website说:Face.com API从python上传图像
该上传相片A请求必须被形成为使用POST数据发送的MIME多部分 消息。应将每个参数(包括原始图像 数据)指定为单独的表单数据块。
问题是,我不确切地知道这意味着什么。现在我的代码如下所示:
import urllib
import json
apikey = "[redacted]"
secret = "[redacted]"
img = raw_input("Enter the URL of an image: ");
url = "http://api.face.com/faces/detect.json?api_key=" + apikey + "&api_secret=" + secret + "&urls=" + urllib.quote(img) + "&attributes=all"
data = json.loads(urllib.urlopen(url).read())
如何将其转换为与本地存储的图像一起使用?
使用请求:http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file –