You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
import re
|
|
|
|
|
|
# 针对文件名进行数据清洗
|
|
def clean_file_names(filename: str):
|
|
"""
|
|
针对文件名进行数据清洗
|
|
:param filename:
|
|
:return:
|
|
"""
|
|
# 移除所有非字母、数字、点和下划线的字符
|
|
cleaned = re.sub(r"[^\w.-]|[\s\r\n]*", "", filename)
|
|
# 确保文件名不为空
|
|
if not cleaned:
|
|
cleaned = "untitled"
|
|
return cleaned
|