在API调用中使用下面的代码片段,即可避免添加Bearer验证。
import requests
headers = {'Content-Type': 'application/json'}
response = requests.get(url, headers=headers) # 用GET方法调用API
在上面的代码中,我们设置了请求头为Content-Type
为application/json
,但没有添加Bearer验证。这个方法对于一些不需要验证的API调用非常有用。
下一篇:不要添加空值