optimize code
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import platform
|
||||
import threading
|
||||
from typing import Any
|
||||
from loguru import logger
|
||||
@@ -23,6 +24,7 @@ def get_response(status: int, data: Any = None, message: str = ""):
|
||||
|
||||
|
||||
def to_json(obj):
|
||||
try:
|
||||
# 定义一个辅助函数来处理不同类型的对象
|
||||
def serialize(o):
|
||||
# 如果对象是可序列化类型,直接返回
|
||||
@@ -49,6 +51,8 @@ def to_json(obj):
|
||||
|
||||
# 序列化处理后的对象为JSON字符串
|
||||
return json.dumps(serialized_obj, ensure_ascii=False, indent=4)
|
||||
except Exception as e:
|
||||
return None
|
||||
|
||||
|
||||
def get_uuid(remove_hyphen: bool = False):
|
||||
|
||||
Reference in New Issue
Block a user