问题场景:
如果把test01拿出来单独作为一个文件,作用仅加密,然后返回header, test02在另一个文件里,去调用test01得到header,再发送request时就提示401,发现拿到的header是一样的,下面加密和发送请求在一个文件里就正常,为啥???
a.py
class test01():
def get_auth(url,method_type,payload,params)):
各种加密函数
return auth
class test02():
def tt(url,method_type,payload,params):
auth = test01().get_auth(url,method_type,payload,params))
header = {"auth": auth}
response = request(url,method_type,payload,params,header)
if __name__ == "main":
url
method_type
payload
params
a = test02()
res = a.tt(url,method_type,payload,params)