From 3fbe15ee30566fe4a36e72d845305173f9ec994c Mon Sep 17 00:00:00 2001 From: zhanghan2021 Date: Tue, 28 Nov 2023 09:39:45 +0800 Subject: [PATCH] Delete the specified text file --- common/file.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 common/file.py diff --git a/common/file.py b/common/file.py new file mode 100644 index 0000000..65251aa --- /dev/null +++ b/common/file.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- +# cython:language_level=3 + +import os +from common.config import Config + +# file operation class +class FileOperation: + + @staticmethod + def remove_txt_file(file_name): + ''' + empty file + ''' + if os.path.exists(Config.get_output_path() + file_name): + os.remove(Config.get_output_path() + file_name) + else: + # os.mkdir(Config.get_output_path() + file_name) + file = open(Config.get_output_path() + file_name,'w') + file.close() -- Gitee