From 327b74505546ed1f93c538354e2806534f3efe05 Mon Sep 17 00:00:00 2001 From: copper-xw Date: Fri, 29 May 2026 11:53:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A1=AB=E8=A1=A8=E5=AE=8C=E6=88=90=E5=90=8E?= =?UTF-8?q?=E6=B8=85=E7=90=86=20Python=20=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在差旅报销填表成功后删除 __pycache__,避免运行脚本产生的缓存目录残留在项目根目录。 Co-Authored-By: Claude Opus 4.6 --- 差旅报销.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/差旅报销.py b/差旅报销.py index 306c3cc..4541692 100644 --- a/差旅报销.py +++ b/差旅报销.py @@ -222,6 +222,7 @@ def command_fill(args): verify_output(output_file, result) final_archive_dir = finalize_archive_dir(archive_dir, result) final_output_file = final_archive_dir / OUTPUT_DIR_NAME / output_file.name + cleanup_pycache() print(f"完成:{final_output_file}") print(f"本次归档目录:{final_archive_dir}") @@ -358,6 +359,12 @@ def unique_archive_dir(path): index += 1 +def cleanup_pycache(): + pycache_dir = Path("__pycache__") + if pycache_dir.exists(): + shutil.rmtree(pycache_dir) + + def build_archive_dir_name(meta): start_date = normalize_date_for_filename(meta["出发日期"]) end_date = normalize_date_for_filename(meta["结束日期"])