游雁
2023-12-15 298ddd13fbf833cd77a3a26659e9187e751d140a
1
2
3
4
5
6
7
8
9
10
11
12
13
import importlib
 
 
def dynamic_import(import_path):
    """dynamic import module and class
 
    :param str import_path: syntax 'module_name:class_name'
    :return: imported class
    """
 
    module_name, objname = import_path.split(":")
    m = importlib.import_module(module_name)
    return getattr(m, objname)