2024年5月10日
摘要: 【一】单例模式 让一个类只创建一个对象,即所有对象都是一样的 1)元类 class MyType(type): def __init__(cls, name, bases, name_space): # 给自己的类加一个属性:instance初始值None cls.instance = None s 阅读全文
posted @ 2024-05-10 15:22 晓雾-Mist 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 【一】内置方法补充 1)__call__ # __call__:当类()或对象()调用时触发 class Eg: def __init__(self): print('执行__init__') def __call__(self, *args, **kwargs): print('执行__call_ 阅读全文
posted @ 2024-05-10 15:21 晓雾-Mist 阅读(2) 评论(0) 推荐(0) 编辑