一、单例模式
a、单例模式分为四种:文件,类,基于__new__方法实现单例模式,基于metaclass方式实现
b、类实现如下:
class Sigletion(objects):
import time
def __init__(self):
time.sleep(1)
@classmethod
def instance(cls,*args,**kwargs)
if not hasattr(Sigletion,'_instance'):
Sigletion._instance=Sigletion(*args,**kwargs)