文件名称:linux 网站搭建
文件大小:275KB
文件格式:RTF
更新时间:2021-11-22 03:48:59
web
class Singleton(object): def __new__(cls, *args, **kwargs): if not hasattr(cls, 'instance'): cls.instance = super(Singleton, cls).__new__(cls) return cls.instance class MyClass(Singleton): def __init__(self, name): if name: self.name = name obj1 = MyClass('小明') print(obj1.name) obj2 = MyClass('小红') print(obj2.name) linux 网站搭建