手写一个单例:
class A(object):
instance=None
def__new(cls, *args, **args):
if cls.__instance is None:
cls.__instance=object.new(cls)
return cls.__instance
else:
return cls.__instance
手写一个单例:
class A(object):
instance=None
def__new(cls, *args, **args):
if cls.__instance is None:
cls.__instance=object.new(cls)
return cls.__instance
else:
return cls.__instance