注意python request get请求参数是params,post的请求参数用data。不然容易报错400,请求语法错误
# -*- coding: utf-8 -*-
# @Time : 2020/11/17 11:38
# @Author : Liqiju
# @File : GetToken.py
# @Software : PyCharm
import requests
url ='http://192.168.XXX.XX:XXXX/api/fob/places/list'
data = {"currentPage":1,"pageSize":20,"grade":""}
headers = {"Authorization":"bearer a809655f-e4bf-41b8-9088-85a1d3780d6d"}
#headers = {'Content-Type':'application/json;charset=UTF-8',"Authorization":"bearer a809655f-e4bf-41b8-9088-85a1d3780d6d"}
res = requests.get(url=url,params=data,headers=headers)
print(res.text)
headers里面的'Content-Type':'application/json;charset=UTF-8',可不写。
看看结果
成功返回。