1,接口关联……………………………………………………………………………………
# 全局上下文:保存接口关联变量
class Context:
# 所有关联数据存在这里
_data = {}
# 设置变量:保存数据
@classmethod
def set(cls, key, value):
cls._data[key] = value
# 获取变量:使用数据
@classmethod
def get(cls, key):
return cls._data.get(key)
# 清空数据(可选)
@classmethod
def clear(cls):
cls._data.clear()
2,调用………………………………………………………………………………………………
Context.set("token":token)
Context.get("token")
Context.clear()