标签:UNC col == 模块 art imp pat attr rtl
一、mon.py:
class Mon: def __init__(self): pass def action(self, content): print(‘周一要{}‘.format(content))
二、tue.py:
class Tue: def __init__(self): pass def action(self, action): print(‘周二要{}‘.format(action))
三、wed.py:
class Wed: def __init__(self): pass def action(self, action): print(‘周三要{}‘.format(action))
四、settings.py:
EX_FUNCS_LIST = [ ‘ex_funcs.mon.Mon‘, ‘ex_funcs.tue.Tue‘, ‘ex_funcs.wed.Wed‘ ]
五、__init__.py:
import settings import importlib def cmd(content): for path_str in settings.EX_FUNCS_LIST: module_path, class_name = path_str.rsplit(‘.‘, maxsplit=1) module = importlib.import_module(module_path) cls = getattr(module, class_name) obj = cls() obj.action(content)
六、start.py:
import ex_funcs if __name__ == ‘__main__‘: ex_funcs.cmd(‘工作‘)
标签:UNC col == 模块 art imp pat attr rtl
原文地址:https://www.cnblogs.com/caoyu080202201/p/13070128.html