python单例模式设计

class MyTest():
my_obj = None
def __new__(cls,*args,**kwargs):
if not cls.my_obj:
cls.my_obj =object.__new__(cls,*args,**kwargs)
return cls.my_obj

 

posted @ 2021-04-19 15:43  末年926  阅读(32)  评论(0编辑  收藏  举报