标签:mode 技术 应用 settings 导入 png div obj list
看django源码,感觉他的settings好高大上然后自己试试
以上是文件目录
email.py中代码
class Email: def send(self): print(‘发送email‘)
Msg.py有类似的代码
class Msg: def send(self): print(‘msg‘)
Phone.py
class Phone: def send(self): print(‘phone‘)
settings.py
NOTIFY_LIST = [ ‘s123.email.Email‘, ‘s123.Msg.Msg‘, ‘s123.Phone.Phone‘, ]
from setting import * import importlib def send_xxx(): for i in NOTIFY_LIST: model_name, class_name = i.rsplit(‘.‘, maxsplit=1) model = importlib.import_module(model_name) class_name = getattr(model, class_name) obj = class_name() obj.send()
import s123 if __name__ == ‘__main__‘: s123.send_xxx()
标签:mode 技术 应用 settings 导入 png div obj list
原文地址:https://www.cnblogs.com/Stay-J/p/8809893.html