首页 > 解决方案 > 如何使用多个标头执行 GET 请求?

问题描述

尝试将多个标头放入我的GET请求时出现语法错误。

我尝试将 Content-Type 和 Authorization 周围的 '' 更改为 "",因为我在这里看到过涉及它们的帖子,但似乎都不起作用。这是我的代码。

import json
import requests
url = 'https://api.website.com/testpost'
headers = {

        'Content-type': 'application/json'
        'Authorization': 'Bearer placeholdertoken'
}
response= requests.get(url, headers=headers)
print(response)

我应该得到答案,但在授权后我在“:”处收到语法错误

标签: pythonjsonpython-3.xapipython-requests

解决方案


您没有在键值对之后放置逗号


推荐阅读