标签:dog instance bsp obj def 单例对象 highlight div one
单例对象:
每次调用都是同一个对象
单例对象的创建
class Dog(object):
    __instance = None
    
    def __new__(cls):
        if cls.__instance == None:
            cls.instance = object.__new__(cls)
            return cls.__instance
    else:
        return cls.__instance
标签:dog instance bsp obj def 单例对象 highlight div one
原文地址:https://www.cnblogs.com/zmw-1997/p/9529594.html