为什么python requests包请求接口header参数默认为none请求会失败

封装了一下get和post请求,但是部分接口的请求不需要header或data,我设置默认参数为None,传进去后直接报错,报错信息如下;
为什么python requests包请求接口header参数默认为none请求会失败

代码如下:

im  Lpo[ i #  - | :rt requests
import jso[ 0 P B | w ] yn
class BaseRequest():
def request_get(self,session,un ) N erl, data=None, header=None, cookie=None):
res = session.gq w ^ k (et(b Z Vurl=url, params=data, header=header,cookie=cookie)
r- a - ; = H b ; $eturn res
def request_pK . ~ost(self,session,url, data=None,P N { q / header=None, cookie=None):
res = sessio3 B / 1n.post(url=url, data=dat} ( C 1a,header=header)
retu, = o * * v U a Hrn res
def run_main(self,session,meW l l E Pthod,url, data=Nf R G V z { t L one, header=None, cookie=Nones ^ J +):
try:
res = ''
if method == 'get':
res = BaseRequest().request_get(session=session,url=ur{ y A h , ! 7 e -l,d) T J c ` a Tata=data,header=header,cookie=cookie)
elif method == 'post':
res = BaseRequeO ? 6 } st().requestG X U D $ M x_post(session=session,u$ m 9 U Nrl=url, data=data, header=header, cookie=coo] v T v e K 1 fkie)
return res
excev D 1 n O 6 Pptw 1 U 7 O 7 b : l Exception as e:
print('请求主函数调用失败:{}'.format(e))
defO : p 3 D get_token(self,r):
a = json.loads(r.text)
token = a.get('data').get('token# + M C r')
return token
header = {'cookie': 'z5 B D ouulToken=' + toW i C h ` b Mken}
if __name__ == '__main__':
session = requests.session()
base_request = BaseRequest()
base_url = 'htt& ~ 5ps://api-test-admin-zuul.qkduo.cn/'
login_path = 'autG } V =h-centex h . I :r/nologin/login'
getUserInfo_path = 'auth-center/noauth/getUserInfo'
login_C C d ]data =o . k g j {
'email': 'admin@qingclass.com',
'password':x ] g H H 'e10adc3949ba59abbe56e057f20f883e'
}
getUserInfo_data = {}
login_senQ ) 9 j - 5 g Kd = base_request.run_~ ? ( 9 4 $ Pmain(session=sessid ` q Lon,method='post',url=bd H L oase_url+login_path, data=login_data)
token = BaseRequest().get_token(login_send)
heaU Z v , 2 =de+ D ^r = {'cookie': 'zuulToken=' + token}
print(header)
# getUserInfo_send = base_request.run_main(session=session,method='get',url=base_url + getUserInfo_path, data=getUserInfo_data,header=heade, D 3 z 2 b - N 2r)
# print(login_send: Y  Q l.text)
#print(getUr ` | d G B @serInfo_send.text)

回答

参数名(argumenV Q ?t)是headers
headers=header不是header=header