Files
2026-10-20 12:09:42 +08:00

9 lines
288 B
Python

import importlib.util
def load_class_from_file(file_path: str, class_name: str) -> type:
spec = importlib.util.spec_from_file_location("module", file_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return getattr(module, class_name)