摘要:        
# Python 3.5 之后可用,之前需要pip安装 from typing import TypedDict # 每个字段必须 class Person(TypedDict): name: str age: int qq: str p1_dict: Person = { "name": "大佬"    阅读全文
posted @ 2023-11-28 21:01
zwnsyw
阅读(149)
评论(0)
推荐(0)
        
            
        
        
摘要:        
import threading import time def singleton(cls): instances = {} def get_instance(*args, **kwargs): # 判断实例是否已经存在 if cls not in instances: # 如果不存在,创建新的实    阅读全文
posted @ 2023-11-28 20:13
zwnsyw
阅读(34)
评论(0)
推荐(0)
        
            
        
        
摘要:        
# 定义接口类 from abc import ABC, abstractmethod class Animal(ABC): @abstractmethod def speak(self): pass # 定义实现类 class Dog(Animal): def speak(self): retur    阅读全文
posted @ 2023-11-28 15:44
zwnsyw
阅读(109)
评论(0)
推荐(0)
        

 浙公网安备 33010602011771号
浙公网安备 33010602011771号