单例模式
class Demo(object):
__instance = None
def __new__(cls, *args, **kwargs):
if cls.__instance is None:
cls.__instance = object.__new__(cls)
return cls.__instance
else:
return cls.__instance
A = Demo()
B = Demo()
print(A)
print(B)
# <__main__.Demo object at 0x1037fd8d0>
# <__main__.Demo object at 0x1037fd8d0>