27 lines
542 B
Python
27 lines
542 B
Python
|
|
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()
|