python - CURL 有效,但不能翻译成 Python
问题描述
以下 CURL 代码可在 cmd 中完美运行:
curl -X POST -H "Authorization: Bearer MY_KEY" ^
-H "Content-Type: multipart/form-data;" ^
-F "center=40.430,-3.702" ^
-F "propertyType=homes" ^
-F "distance=15000" ^
-F "operation=sale" ^
"https://api.idealista.com/3.5/es/search"
,但如果我使用https://curl.trillworks.com/将其翻译成 Python 代码,如下所示:
import requests
headers = {
'Authorization': 'Bearer MY_KEY',
'Content-Type': 'multipart/form-data;',
}
files = {
'center': (None, '40.430,-3.702'),
'propertyType': (None, 'homes'),
'distance': (None, '15000'),
'operation': (None, 'sale'),
}
response = requests.post('https://api.idealista.com/3.5/es/search', headers=headers, files=files)
,好吧,然后它不再起作用,给出错误500。似乎是什么问题?
解决方案
推荐阅读
- android - 搜索菜单未显示在片段中
- python - 使用 PropertyMock 模拟类变量
- python - 挖掘“包含在”条目而不是“等于”的术语
- c++ - 将对象声明为抽象类
- tensorflow - 我在运行带有 20k 新数据集的 PRE TRAINED Bert 模型时遇到了 OOM
- http - 自研HTTP服务器
- swiftui - Swiftui ScrollViewreader 多个 ScrollTo 在不同的 Foreach
- firebase - 如何从 Firebase 实时数据库中的一张表中获取数据
- matlab - MATLAB 拟合工具中的初始猜测不变
- autodesk-forge - 问:查看器性能问题?