目录html
python写的程序多了,发现不少方法,不少小工具能够复用,记录起来,作成目录,或者直接贴代码python
class Singleton: """单例""" _instance_lock = Lock() # 新建实例用到的锁 def __init__(self, hub_url): pass def __new__(cls, *args, **kwargs): if not hasattr(Singleton, "_instance"): with Singleton._instance_lock: if not hasattr(Singleton, "_instance"): Singleton._instance = object.__new__(cls) Singleton._instance.hub_url = args[0] # 属性赋值什么的,好像只能放在这 return Singleton._instance
Loggingmysql
计时装饰器git
def timer(func): @functools.wraps(func) def wrapper(*args, **kwargs): start = time.time() print('开始时间: {}'.format(start)) result = func(*args, **kwargs) ended = time.time() print('结束时间: {}, 耗时: {}'.format(ended, ended-start)) return result return wrapper
增删查改(待更)redis
(待更)sql
解析库,(待更)docker