from abc import ABC from datetime import datetime import hashlib class SingletonFunction(ABC): """ 提供公共函数和功能函数 """ def __init__(self): pass @staticmethod def call_datetime(need_str: bool = True): return str(datetime.now()) if need_str else datetime.now() @staticmethod def md5sum(string: str): md5 = hashlib.md5() password = string.encode("utf-8") md5.update(password) return md5.hexdigest() singleton_function = SingletonFunction()