python - 如何使用多个标头执行 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)
我应该得到答案,但在授权后我在“:”处收到语法错误
解决方案
您没有在键值对之后放置逗号
推荐阅读
- file - 上传文件时托管网站自己的服务器如何选择我的计算机目录?
- python - 检查该项目是否存在于 OrderedDict 的字典中
- java - 如何使用 Java swing 备份 MySQL 数据库中的单个表?
- javascript - Vaadin-tooltip 有时不显示。怎么了?如何以编程方式显示它?
- java - 通过 apache HttpClient 3.1 在大型 HTTP MultipartRequestEntity 上的 OutOfMemory
- java - Google Cloud Dataflow 服务帐户未传播给工作人员?
- excel - 如何从时间线切片器恢复结束日期和开始日期值并将它们放入单元格
- python - 通过创建 Firebase 实时数据库的事件类型触发了带有 Python 的 Cloud Function
- javascript - 我应该在 JS 中测试静态本地文件吗?
- c# - 如何在c#中为多个条件保存数据