返回:JSON 格式的字符串
from app.utils import to_json
data = {'key': 'value'}
json_str = to_json(data)
返回:布尔值,True 表示格式正确
from app.utils import is_email
is_valid = is_email('test@example.com')
返回:布尔值,True 表示格式正确
from app.utils import is_valid_ip
is_valid = is_valid_ip('192.168.1.1')
返回:文件大小(字节)
from app.utils import get_file_size
size = get_file_size('test.txt')
返回:当前时间的 datetime 对象
from app.utils import get_current_time
now = get_current_time()
返回:格式化后的字符串
from app.utils import format_date
now = get_current_time()
formatted = format_date(now)
返回:解析后的 datetime 对象
from app.utils import parse_date
dt = parse_date('2023-01-01 12:00:00')
返回:当前时间的时间戳(秒)
from app.utils import get_timestamp
ts = get_timestamp()
from app.utils import ...
的方式按需导入工具方法