From d6974f2192c0115660b9f683d22f57c2425aa675 Mon Sep 17 00:00:00 2001 From: W1ndys Date: Sat, 11 Jan 2025 18:02:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=20replace=5Fimage=5Flink.py=20?= =?UTF-8?q?=E4=B8=AD=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD=EF=BC=9A=E5=9C=A8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0Markdown=E6=96=87=E4=BB=B6=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E9=93=BE=E6=8E=A5=E5=90=8E=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8E=9F=E5=A7=8B=E5=9B=BE=E7=89=87=E6=BA=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=B9=B6=E8=AE=B0=E5=BD=95=E6=97=A5=E5=BF=97=E3=80=82?= =?UTF-8?q?=E8=BF=99=E5=A2=9E=E5=BC=BA=E4=BA=86=E8=84=9A=E6=9C=AC=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=80=A7=E5=92=8C=E6=B8=85=E7=90=86=E8=83=BD?= =?UTF-8?q?=E5=8A=9B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- replace_image_link.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/replace_image_link.py b/replace_image_link.py index eaa572786..d69c5896e 100644 --- a/replace_image_link.py +++ b/replace_image_link.py @@ -47,6 +47,10 @@ def update_markdown_images(md_file_path): logging.info(f"将图片链接 {image_path} 替换为 {new_image_link}") # 替换Markdown中的图片链接 content = content.replace(image_path, new_image_link) + + # 删除图片源文件 + os.remove(absolute_image_path) + logging.info(f"已删除图片源文件: {absolute_image_path}") else: logging.warning(f"图片路径 {absolute_image_path} 不存在")