第三题: class Singleton(object): __instance = None def __new__(cls, *args, **kwargs): if cls.__instance == None: cls.__instance = super(Singleton, cls).__new__(cls, *args, **kwargs) return cls.__instance s1 = Singleton() s2 = Singleton() print(s1) print(s2) |