requests包是python语言里的一个发送请求的很好用的包,它集成了很多http请求方式,本文重点介绍一下post的提交形式。
服务端的API有的接受form表单提交,有的接受json数据提交,他们的python编写区别如下:
form:
header = {
"Content-Type": "application/x-www-form-urlencoded"
}
requests.post(url , data={"appname": '111'}, headers=header)
json:
header = {
"Content-Type": "application/json"
}
requests.post(url , data={"appname": '111'}, headers=header)
两者的主要区别在于headers里。