首页 > 编程语言 > 详细

python http post简单例子

时间:2021-04-21 16:07:36      阅读:21      评论:0      收藏:0      [点我收藏+]

仅做post跟返回,一般作为接口测试数据请求以及返回数据是否正确,辅CPP

#code=utf-8
import requests
import sys

data = {‘account‘: ‘12345678@qq.com‘, ‘pass‘: ‘llq‘, ‘type‘: ‘0‘, ‘level‘: ‘1‘}
token = "1249593182902824962:client:34a36980c093151b31874e9d2c28fe97"
#head = {‘token‘: token, ‘Content-Type‘: ‘application/json; charset=UTF-8‘}
head = {‘Content-Type‘: ‘application/json; charset=UTF-8‘}

loginId = "1275363433375326209"
userName = ""
password = ""
loginData = {‘account‘: userName, ‘pass‘: password, ‘type‘: ‘0‘, ‘level‘: ‘1‘}
requestData = {‘loginId‘: ‘1275384431030034433‘}
url = ‘url = xxx‘

mainUrl = postUrl.loginUrl

#url = postUrl.loginInfo + "?loginId=" + loginId
print(mainUrl)
#res = requests.post(url, params = requestData, headers= head)
res = requests.post(mainUrl, params = data, headers= head)
#res = requests.get(url, headers = head)

response = res.json()
print(response)

python http post简单例子

原文:https://www.cnblogs.com/liuruoqian/p/14684700.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!