我正在使用流行的请求库来从API请求数据。以下作品:
import requests
parameters = {
'action': 'query_plugins',
'per_page': 10,
'browse': 1,
'page': 1,
}
response = requests.get('https://api.wordpress.org/plugins/info/1.1/', parameters)
results = response.json()
print(results)
但是有一些嵌套的参数,例如,这是我可能查询的URL:
https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[per_page]=10&request[browse]=1&request[page]=1&request[fields][description]=0&request[fields][sections]=0'
在上述情况下,我需要传递以下嵌套参数:
request[fields][description]
request[fields][sections]
如何做到这一点?
参考方案
如果我正确阅读了this issue,则可以简单地使用方括号名称作为参数的键(请参见this comment):
import requests
parameters = {
'action': 'query_plugins',
'per_page': 10,
'browse': 1,
'page': 1,
'request[fields][description]': 0,
'request[fields][sections]': 0
}
response = requests.get('https://api.wordpress.org/plugins/info/1.1/', parameters)
results = response.json()
Python-使用请求时发布请求失败 - python使用外壳程序时,我可以通过运行以下命令成功创建新用户curl --user administrator:pasword "Content-Type: application/json" https://localhost:8080/midpoint/ws/rest/users -d @user.json但是,当我尝试使用请求在python…
在返回'Response'(Python)中传递多个参数 - python我在Angular工作,正在使用Http请求和响应。是否可以在“响应”中发送多个参数。角度文件:this.http.get("api/agent/applicationaware").subscribe((data:any)... python文件:def get(request): ... return Response(seriali…
Python exchangelib在子文件夹中读取邮件 - python我想从Outlook邮箱的子文件夹中读取邮件。Inbox ├──myfolder 我可以使用account.inbox.all()阅读收件箱,但我想阅读myfolder中的邮件我尝试了此页面folder部分中的内容,但无法正确完成https://pypi.python.org/pypi/exchangelib/ 参考方案 您需要首先掌握Folder的myfo…
R'relaimpo'软件包的Python端口 - python我需要计算Lindeman-Merenda-Gold(LMG)分数,以进行回归分析。我发现R语言的relaimpo包下有该文件。不幸的是,我对R没有任何经验。我检查了互联网,但找不到。这个程序包有python端口吗?如果不存在,是否可以通过python使用该包? python参考方案 最近,我遇到了pingouin库。
Python ThreadPoolExecutor抑制异常 - pythonfrom concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED def div_zero(x): print('In div_zero') return x / 0 with ThreadPoolExecutor(max_workers=4) as execut…