From c5de2ae0720d6135ff56b3fe3b456b7da3c9095f Mon Sep 17 00:00:00 2001 From: Caohongtao Date: Wed, 1 Nov 2023 02:40:00 +0000 Subject: [PATCH] =?UTF-8?q?update=20src/toolService.py.=20=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=9C=A8=E6=96=87=E4=BB=B6=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E5=86=8D=E8=BF=9B=E8=A1=8C=E5=86=99=E6=93=8D=E4=BD=9C=EF=BC=8C?= =?UTF-8?q?=E5=90=A6=E5=88=99=E8=B7=B3=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Caohongtao --- src/toolService.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/toolService.py b/src/toolService.py index 86e8669..bfde658 100644 --- a/src/toolService.py +++ b/src/toolService.py @@ -40,8 +40,11 @@ class ToolService: """ 将内容写入文件。 """ - with open(filename, 'w') as f: - f.write(content) + try: + with open(filename, 'w') as f: + f.write(content) + except FileNotFoundError: + raise FileNotFoundError('The file is not exist') def mkdirs(self, path): """ -- Gitee