仪表盘
版本库
文件存储
活动
搜索
登录
main
/
dust-manage-python
扬尘监测数据爬取
概况
操作记录
提交次数
目录
文档
分支
对比
blame
|
历史
|
原始文档
first commit
riku
2024-01-10
a9e8e27e0503552b7b2a99c821da732175d4f071
[dust-manage-python.git]
/
src
/
decorator
/
singleton.py
1
2
3
4
5
6
7
8
9
10
11
def singleton(cls):
"""单例模式修饰器"""
__instance = {}
def wrapper(*args, **kwargs):
if cls not in __instance:
__instance[cls] = cls(*args, **kwargs)
return __instance[cls]
else:
return __instance[cls]
return wrapper