seetings.py
class Foo: TEST = True
test.py
import importlib # 如何根据字符串找到类 path = "settings.Foo" p, c = path.rsplit('.', maxsplit=1) m = importlib.import_module(p) cls = getattr(m,c) print(dir(cls)) for key in dir(cls): if key.isupper(): print(key,getattr(cls,key))