代码如下:
import requests url = "http://****.**.****.com/passportSeparate/login" header = {"Content-Type":"application/json;charset=UTF-8" } req_data = { "username": "ABC123", "timestamp": "y8VfBZlmz+LkaaceYih5HA==", "token": "NULL", "sign": "r1aGZPSx2pHjBnLTfLo4HaqNFaGwhmpgaqd5X0E7T2E=", "appSystem": "034001", "ip": "127.0.0.1", "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.35", "password": "123456A", "scanId": "", "smsCode": "", "loginName": "ABC123" } resp = requests.post(url, json=req_data, header=header) print(resp.text)
报错如下:
Traceback (most recent call last):
File "D:/InterFrame/testcases/test.py", line 18, in <module>
resp = requests.post(url, json=req_data, header=header)
File "D:\InterFrame\venv\lib\site-packages\requests\api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "D:\InterFrame\venv\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
TypeError: request() got an unexpected keyword argument 'header'
解决方法:
TypeError:request()获得意外的关键字参数“header”
仔细检查是headers少敲了一个s
标签:TypeError,keyword,url,request,header,json,requests,data From: https://www.cnblogs.com/liyongmei/p/16892277.html