now = time.time()
#key
key = settings.TOKEN_KEY
#官方jwt
return jwt.encode({"teacher_account":teacher_account,"exp":now+exp},key,algorithm="HS256")
jwt 参数payload必须是字典 ,否则报错
例如:
`
now = time.time()
#payload
payload={"teacher_account":teacher_account,"exp":now+exp}
#key
key = settings.TOKEN_KEY
#官方jwt
return jwt.encode(payload,key,algorithm="HS256")`
这样书写会报错,TypeError: Expecting a mapping object, as JWT only supports JSON objects as payloads.请大家注意