摘要: 1、文件读写 # 写入文件 with open('example.txt', 'w') as file: file.write('Hello, World!') # 读取文件 with open('example.txt', 'r') as file: content = file.read() p 阅读全文
posted @ 2024-06-29 20:05 wanghongwei-dev 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 单例模式 # 方法 1: 使用类变量 class Singleton: _instance = None def __new__(cls, *args, **kwargs): if not cls._instance: cls._instance = super(Singleton, cls).__ 阅读全文
posted @ 2024-06-29 20:05 wanghongwei-dev 阅读(6) 评论(0) 推荐(0) 编辑