Python3 利用requests 库进行post携带账号密码请求数据的方法
作者:haeasringnar 时间:2023-04-03 05:37:53
如下所示:
import urllib,json,requests
url = 'http://127.0.0.1:8000/account/login'
headers = {}
data = {'username':'asd','pwd':'123456$'}
request = requests.post(url=url, data=data,json=True,headers=headers)
response = request.content.decode()
#需要携带请求头信息的可以全部写在headers里面,data就是请求体,需要携带其他信息的也可以另外再加
print(response)
#一般情况下就可以请求成功得到返回值
如果请求失败,那么就是跨域问题或者参数错误。
来源:https://blog.csdn.net/haeasringnar/article/details/81224127
标签:Python3,requests,post
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
详解 Python中LEGB和闭包及装饰器
2023-05-19 00:16:41
Javascript中级语法快速入手
2024-04-26 17:11:02
python读取excel进行遍历/xlrd模块操作
2022-11-09 18:44:51
![](https://img.aspxhome.com/file/2023/0/128290_0s.jpg)
用Python自动下载网站所有文件
2021-02-09 18:57:35
![](https://img.aspxhome.com/file/2023/3/64983_0s.jpg)
PHP中定义数组常量(array常量)的方法
2023-11-23 06:16:59
go语言中的协程详解
2024-03-13 00:42:24
![](https://img.aspxhome.com/file/2023/0/105140_0s.png)
python yield关键词案例测试
2021-02-07 03:14:07
Python模拟登录和登录跳转的参考示例
2023-07-29 07:09:47
Python简单的GUI程序示例详解
2021-04-10 20:17:16
![](https://img.aspxhome.com/file/2023/0/93590_0s.png)
np.newaxis()函数的具体使用
2022-01-10 08:38:27
python sorted函数的小练习及解答
2021-10-14 15:50:28
MySQL8.0中binlog的深入讲解
2024-01-16 23:22:02
![](https://img.aspxhome.com/file/2023/2/96492_0s.png)
Python自动登录QQ的实现示例
2021-09-07 19:50:26
简析 IOS 程序图标的设计
2011-04-28 09:39:00
Pytes正确的配置使用日志功能
2023-07-18 05:51:17
如何运行Python程序的方法
2023-01-13 07:56:03
![](https://img.aspxhome.com/file/2023/6/86686_0s.jpg)
Django瀑布流的实现示例
2021-05-09 10:07:42
![](https://img.aspxhome.com/file/2023/3/134673_0s.jpg)
asp.net下利用js实现返回上一页的实现方法小集
2024-05-28 15:37:22
用Python编写个解释器实现方法接受
2023-01-11 15:50:08
![](https://img.aspxhome.com/file/2023/5/65505_0s.png)
Pytorch中实现CPU和GPU之间的切换的两种方法
2021-08-21 07:24:18