1. 首页
  2. 数据库
  3. 其它
  4. Python设计模式之单例模式实例

Python设计模式之单例模式实例

上传者: 2020-12-31 17:29:50上传 PDF文件 49.94KB 热度 21次
注:使用的是Python 2.7。 一个简单实现复制代码 代码如下:class Foo(object): __instance = None def __init__(self): pass @classmethod def getinstance(cls): if(cls.__instance == None): cls.__instance = Foo() return cls.__instance if __name__ == ‘__main__’: foo1 = Foo.getinstance
下载地址
用户评论