diff --git a/photo_review/util/data_util.py b/photo_review/util/data_util.py index dd26895..76ea4fc 100644 --- a/photo_review/util/data_util.py +++ b/photo_review/util/data_util.py @@ -27,8 +27,8 @@ def handle_date(string): string = string.replace("年", "-").replace("月", "-").replace("日", "").replace("/", "-").replace(".", "-") string = re.sub(r'[^0-9-]', '', string) + string = string.strip("-") if "-" in string: - string = string.strip("-") dash_count = string.count("-") if dash_count > 2: third_dash_index = string.find("-", string.find("-", string.find("-") + 1) + 1) @@ -118,3 +118,7 @@ def handle_original_data(string): return "" # 防止过长存入数据库失败 return string[:255] + + +if __name__ == '__main__': + print(handle_date("2024年"))