GET(带参) 请求 配置params参数
作者:互联网
import requests
#发送网络请求
response = requests.get('http://httpbin.org/get?name=Jack&age=30')
print(response.text)
输出结果:
{
"args": {
"age": "30",
"name": "Jack"
},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Host": "httpbin.org",
"User-Agent": "python-requests/2.24.0",
"X-Amzn-Trace-Id": "Root=1-5fc44110-56f73ef208892acf2eb21482"
},
"origin": "124.91.67.209",
"url": "http://httpbin.org/get?name=Jack&age=30"
}
Process finished with exit code 0
配置params参数
import requests
data = {'name':'Michael','age':'36'}
#发送网络请求
response = requests.get('http://httpbin.org/get', params=data)
print(response.text)
输出结果:
{
"args": {
"age": "36",
"name": "Michael"
},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Host": "httpbin.org",
"User-Agent": "python-requests/2.24.0",
"X-Amzn-Trace-Id": "Root=1-5fc44297-48feebbc6bced3bf3c5aae07"
},
"origin": "124.91.67.209",
"url": "http://httpbin.org/get?name=Michael&age=36"
}
Process finished with exit code 0
标签:httpbin,name,get,age,GET,带参,params,org,requests 来源: https://blog.csdn.net/dai1987csdn/article/details/110366392