class Single(object):
def __new__(cls,*args,**kw):
if not hasattr(cls,"_instance"):
cls._instance=super(Single,cls).__new__(cls,*args,**kw)
return cls._instance
class MyClass(Single):
pass
Python 单例模式
最新推荐文章于 2024-09-04 10:31:20 发布