feat(StringUtils): add url_eqote method

This commit is contained in:
Akimio521
2024-11-08 14:31:08 +08:00
parent 75e80158e5
commit 726e7dfbd4

View File

@@ -805,3 +805,14 @@ class StringUtils:
:return: 如果elem有效非None且长度大于0返回True否则返回False
"""
return elem is not None and len(elem) > 0
@staticmethod
def url_eqote(s:str) -> str:
"""
将字符串编码为 URL 安全的格式
这将确保路径中的特殊字符(如空格、中文字符等)被正确编码,以便在 URL 中传输
:param s: 要编码的字符串
:return: 编码后的字符串
"""
return parse.quote(s)