curl到Python POST请求图像上载输入错误

curl到Python POST请求图像上载输入错误,python,curl,python-requests,Python,Curl,Python Requests,我正在尝试转换此curl命令: curl -X POST -F "images_file=@prez.jpg" "https://gateway-a.watsonplatform.net/visual-recognition/api/v3/detect_faces?api_key={apikey}&version=2016-05-20" 发送到python post请求 使用手册中,但我仍然得到一个无文件上传错误 url = {'https://gateway-a.watsonpla

我正在尝试转换此curl命令:

curl -X POST -F "images_file=@prez.jpg" "https://gateway-a.watsonplatform.net/visual-recognition/api/v3/detect_faces?api_key={apikey}&version=2016-05-20" 
发送到python post请求

使用手册中,但我仍然得到一个无文件上传错误

url = {'https://gateway-a.watsonplatform.net/visual-recognition/api/v3/detect_faces'}
images= {'images_file': ('prez.jpg', open('prez.jpg', 'rb'))}
payload = {'api_key': {apikey}, 'version':'2016-05-20'}
r = requests.post(url, files = images, params = payload)
print(r.text)
以下是Watson API的返回:

{
    "error": {
        "code": 400,
        "description": "No images were specified.",
        "error_id": "input_error"
    },
    "images_processed": 1
}

我上传的文件正确吗?curl命令工作正常,因此问题可能不是图像

这应该符合您的卷曲要求

url = 'https://gateway-a.watsonplatform.net/visual-recognition/api/v3/detect_faces'
images = {'images_file': open('prez.jpg', 'rb')}
payload = {'api_key': "{{{}}}".format(api_key), 'version': '2016-05-20'}
r = requests.post(url, files=images, params=payload)