mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
Update string.py
This commit is contained in:
+5
-1
@@ -945,8 +945,12 @@ class StringUtils:
|
|||||||
自然排序
|
自然排序
|
||||||
将字符串拆分为数字和非数字部分,数字部分转换为整数,非数字部分转换为小写字母
|
将字符串拆分为数字和非数字部分,数字部分转换为整数,非数字部分转换为小写字母
|
||||||
:param text: 要处理的字符串
|
:param text: 要处理的字符串
|
||||||
|
:return 用于排序的数字和字符串列表
|
||||||
"""
|
"""
|
||||||
|
if text is None:
|
||||||
|
return []
|
||||||
|
|
||||||
if not isinstance(text, str):
|
if not isinstance(text, str):
|
||||||
return [text]
|
text = str(text)
|
||||||
|
|
||||||
return [int(part) if part.isdigit() else part.lower() for part in re.split(r'(\d+)', text)]
|
return [int(part) if part.isdigit() else part.lower() for part in re.split(r'(\d+)', text)]
|
||||||
|
|||||||
Reference in New Issue
Block a user