python http post简单例子

仅做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)

posted on 2021-04-21 12:28  流若浅  阅读(815)  评论(0编辑  收藏  举报

导航