去除广告

This commit is contained in:
liuwei
2025-04-15 17:28:32 +08:00
parent 7be1811c1c
commit b382bd8d4a
3 changed files with 33 additions and 10 deletions

15
utils/string_utils.py Normal file
View File

@@ -0,0 +1,15 @@
def remove_trailing_content(text, delimiter='---'):
"""
剔除文本中最后一个指定分隔符及其后面的内容。
参数:
text (str): 输入的文本
delimiter (str): 要查找的分隔符,默认为 '---'
返回:
str: 剔除分隔符及其后面内容后的文本
"""
index = text.rfind(delimiter)
if index != -1:
return text[:index].strip()
return text