问题:
path = "auth.my_auth.AUTH" # 根据path实例化AUTH类
解决:
path = "auth.my_auth.AUTH" import importlib model_path, class_name = path.rsplit(".", 1) model = importlib.import_module(model_path) # 根据"auth.my_auth"导入my_auth模块 obj = getattr(model, class_name)() # 反射并实例化
原文地址:https://www.cnblogs.com/zxc-Weblog/p/9120755.html
时间: 2024-10-10 09:49:48