摘要:        
观察者模式是一种行为设计模式,它允许你定义一种订阅机制,可以在对象事件发生时通知多个观察者对象。下面是一个简单的Python观察者模式代码示例: ```python class Subject: """ 被观察者类,维护观察者列表,并在状态发生改变时通知观察者 """ def __init__(se    阅读全文
posted @ 2023-05-21 17:56
kitai
阅读(137)
评论(0)
推荐(0)
        
            
        
        
摘要:        
Python中有多种实现单例模式的方式,以下是其中的几种: 1. 基础单例模式 ```python class Singleton(object): __instance = None def __new__(cls, *args, **kwargs): if not cls.__instance:    阅读全文
posted @ 2023-05-21 17:36
kitai
阅读(14)
评论(0)
推荐(0)
        
 
                    
                     
                    
                 
                    
                
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号