游雁
2023-12-07 fc246ab820cf57ba08afbe3cbeb4d471036eb83c
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)