札记

  博客园  :: 首页  :: 新随笔  ::  :: 订阅 订阅  :: 管理

2022年3月22日

摘要: 采用装饰器来建立单例模式 def singleton(cls): # 创建一个字典用来保存类的实例对象 _instance = {} def _singleton(*args, **kwargs): # 先判断这个类有没有对象 if cls not in _instance: _instance[c 阅读全文
posted @ 2022-03-22 13:38 小泥巴2008 阅读(236) 评论(0) 推荐(0) 编辑