every blog every motto: What doesn’t kill you makes you stronger.
0. 前言
简单记录一下
1. 正文
1.1 params
1.1.1 get
import requests
# get
dic = {"name":'john',"gender":'1'}
url = 'https://httpbin.org/get'
res = requests.get(url,params=dic)
print(res.text)
1.1.2 post
import requests
dic = {"name":'john',"gender":'1'}
# post
url = 'https://httpbin.org/post'
res = requests.post(url,params=dic)
print(res.text)
1.2 data
1.2.1 get
import requests
# get
dic = {"name":'john',"gender":'1'}
url = 'https://httpbin.org/get'
res = requests.get(url,data=dic)
print(res.text)
1.2.2 post
import requests
dic = {"name":'john',"gender":'1'}
# post
url = 'https://httpbin.org/post'
res = requests.post(url,data=dic)
print(res.text)
1.3 小结
- params 用于将参数添加到url后面,组成一个新的url。(get和post方法皆可)
- data 提交数据以表单的形式提交(不会在url中体现,即url不发生变化,仅post可用)
- 并非(像后文参考文献中提到的)params用于get,data用于post,同样,并没有在官方文档中找到相关依据,其仅分别举例而已。
参考文献
[1] https://blog.csdn.net/chenjineng/article/details/79281127
[2] https://blog.csdn.net/qq544649790/article/details/82844909?utm_medium=distribute.pc_relevant.none-task-blog-searchFromBaidu-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-searchFromBaidu-2.control
[5] https://2.python-requests.org/zh_CN/latest/user/quickstart.html
[4] https://blog.csdn.net/dugushangliang/article/details/90473735
[5] https://www.yht7.com/news/85133