class Foo(): __instance = None @classmethod def get_instance(cls): if cls.__instance: return cls.__instance else: cls.__instance = Foo() return cls.__instance def add(self,a,b): print(a+b)
python单例模式
猜你喜欢
转载自blog.csdn.net/cjh365047871/article/details/80098293
今日推荐
周排行