From 91917e266971d6b74df78ed3df6cd2fcd13ce7a5 Mon Sep 17 00:00:00 2001 From: yinzeyuan <373864470@qq.com> Date: Wed, 31 Aug 2022 22:16:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=BD=A2=E5=8F=82=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- office/core/FileType.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/office/core/FileType.py b/office/core/FileType.py index d178893..fa12ecb 100644 --- a/office/core/FileType.py +++ b/office/core/FileType.py @@ -35,9 +35,9 @@ def replace4filename(self, path, del_content, replace_content): def file_name_insert_content(self, file_path, insert_position: int, insert_content: str): """ - :param Path: 文件存放路径 - :param InsertPosition: 插入位置(内容将插入在此之后,如果输入位置大于文件主名长度将插入在末尾) - :param InsertContent: 插入内容 + :param file_path: 文件存放路径 + :param insert_position: 插入位置(内容将插入在此之后,如果输入位置大于文件主名长度将插入在末尾) + :param insert_content: 插入内容 """ Path = pathlib.Path(file_path).resolve() if Path.is_dir(): @@ -62,8 +62,8 @@ def file_name_insert_content(self, file_path, insert_position: int, insert_conte def file_name_add_prefix(self, file_path, prefix_content: str): """ - :param Path: 文件存放路径 - :param PrefixContent: 前缀内容 + :param file_path: 文件存放路径 + :param prefix_content: 前缀内容 """ Path = pathlib.Path(file_path).resolve() if Path.is_dir(): @@ -82,8 +82,8 @@ def file_name_add_prefix(self, file_path, prefix_content: str): def file_name_add_postfix(self, file_path, postfix_content: str): """ - :param Path: 文件存放路径 - :param PostfixContent: 后缀内容 + :param file_path: 文件存放路径 + :param postfix_content: 后缀内容 """ Path = pathlib.Path(file_path).resolve() if Path.is_dir(): From 3562a144cf61122fd1dae25317ba92e030004d9d Mon Sep 17 00:00:00 2001 From: yinzeyuan <373864470@qq.com> Date: Thu, 1 Sep 2022 02:45:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=97=E8=A1=A8=E5=88=B0Excel=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yinzeyuan/output_file_list_to_excel.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 contributors/yinzeyuan/output_file_list_to_excel.py diff --git a/contributors/yinzeyuan/output_file_list_to_excel.py b/contributors/yinzeyuan/output_file_list_to_excel.py new file mode 100644 index 0000000..2a0cf21 --- /dev/null +++ b/contributors/yinzeyuan/output_file_list_to_excel.py @@ -0,0 +1,24 @@ +import pathlib +import openpyxl + + +def output_file_list_to_excel(dir_path: str): + """ + :param dir_path: 需要生成文件列表的目录 + """ + dir_path = pathlib.Path(dir_path).resolve() + if dir_path.is_dir(): + dir_path_list = list(dir_path.glob("**/*")) + output_excel = openpyxl.Workbook() + output_excel_sheet = output_excel.active + output_excel_sheet.append(["完整路径", "文件所在路径", "文件名"]) + for file_path in dir_path_list: + if file_path.is_file(): + output_excel_sheet.append([str(file_path), str(file_path.parent), str(file_path.name)]) + output_excel.save(dir_path.joinpath("本目录文件列表.xlsx")) + else: + print("请输入正确的文件路径!") + + +if __name__ == '__main__': + output_file_list_to_excel(".")