first commit
This commit is contained in:
16
core/utils.py
Normal file
16
core/utils.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""通用工具模块
|
||||
|
||||
提供项目可能用到的工具函数。
|
||||
"""
|
||||
|
||||
def to_safe_str(value) -> str:
|
||||
"""安全地将任意值转换为字符串
|
||||
|
||||
Args:
|
||||
value: 任意值
|
||||
|
||||
Returns:
|
||||
str: 字符串表示,None 将转换为 ""
|
||||
"""
|
||||
return "" if value is None else str(value)
|
||||
|
||||
Reference in New Issue
Block a user