软件测试技术分享接口测试学习记录

Python requests传参方式

2018-08-24  本文已影响3人  车大侠丶

GET请求

requests.get('http://xxxxxxx/')
payload = {'key1':'value','key2':'value'}
requests.get('http://xxxxxxx/',params=payload)

POST请求

payload = {'key1':'value','key2':'value'}
requests.post('http://xxxxxxx/',data=payload)
payload ={'key1':'value','key2':'value'}
requests.post(url, data=payload,headers={'Content-Type':'application/x-www-form-urlencoded'})
payload ={'some':'data'}
requests.post(url, json=payload,headers={'Content-Type':'application/json'})

payload ={'some':'data'}
requests.post(url, data=json.dumps(payload),headers={'Content-Type':'application/json'})

无论何种方式提交 ,一定要记得加上请求头

上一篇下一篇

猜你喜欢

热点阅读