如何使用python获取格式curl请求和格式到json?

2024-03-28 13:52:48 发布

您现在位置:Python中文网/ 问答频道 /正文

如何使用python以json格式返回响应?在

# Request
curl -H "Authorization: Bearer <personal_access_token>" 
\https://app.asana.com/api/1.0/projects/1331

Tags: httpscomtokenapijsonappaccessrequest
2条回答
import requests
url = 'https://app.asana.com/api/1.0/projects/1331'
headers = {'Authorization': 'Bearer {}'.format(token)}
response = requests.get(url, headers=headers).json()

您应该能够使用requests模块来实现这一点

import requests
requests.get('https://app.asana.com/api/1.0/projects/1331',headers={'Authorization': 'Bearer <personal_access_token>'}).json()

相关问题 更多 >