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

时间:2018-01-15 22:08:06

标签: python json curl request

如何使用python在json中以json的格式获取响应?

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

2 个答案:

答案 0 :(得分: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()

答案 1 :(得分:0)

您应该可以使用requests模块

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