m-gm/framework/singleton_class.py

27 lines
542 B
Python
Raw Normal View History

2025-03-19 18:02:29 +08:00
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()