From dbec37fad5ddf8498a6d631e64d0abb2f5020df7 Mon Sep 17 00:00:00 2001 From: fengbohan <1953356163@qq.com> Date: Wed, 16 Aug 2023 15:47:31 +0800 Subject: [PATCH] =?UTF-8?q?add=20func=EF=BC=9A=E8=8B=A5=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=90=8C=E5=90=8D=E6=96=87=E6=A1=A3=EF=BC=8C?= =?UTF-8?q?=E5=88=99=E4=B8=8D=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReadMe.md | 26 ++++++++++++++++++++++++++ gen_word.py | 7 ++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ReadMe.md diff --git a/ReadMe.md b/ReadMe.md new file mode 100644 index 0000000..041ef0c --- /dev/null +++ b/ReadMe.md @@ -0,0 +1,26 @@ +## 功能列表 + +- 根据上一周的周报,自动生成这周的周报。 + > 替换对应的日期,不会修改工作内容 + > +- 若已经存在同名文档,则不执行 + +## 待添加功能 + +* [ ] + +## 运行程序 + +```powershell +python gen_word.py +``` + +成功运行的log + +```powshell +pre file name: 2023WW32周工作报告_冯博涵.doc; +new file name: 2023WW33周工作报告_冯博涵.doc; +已复制 1 个文件。 +pre_str: 8.7~8.11 +str: 8.14~8.18 +``` diff --git a/gen_word.py b/gen_word.py index 3481161..e3efe57 100644 --- a/gen_word.py +++ b/gen_word.py @@ -7,6 +7,7 @@ from docx.shared import Inches import win32com from win32com.client import Dispatch, constants import os +import sys class WEEK_REPORT: file_name = "" @@ -20,7 +21,11 @@ class WEEK_REPORT: def get_name(self): self.file_name = "{}WW{}周工作报告_冯博涵.doc".format(time.strftime('%Y'), time.strftime('%W')) self.pre_file_name = "{}WW{}周工作报告_冯博涵.doc".format(time.strftime('%Y'), str(int(time.strftime('%W'))-1)) - print("pre file name: {}; \nnew file name: {};".format(self.pre_file_name, self.file_name)) + print("pre file name: {}; \nnew file name: {};".format(self.pre_file_name, self.file_name)) + if(os.path.isfile(self.file_name)==True): + print("{} is already exist.".format(self.file_name)) + sys.exit(1) + def copy_file(self): os.system('copy {} {}'.format(self.pre_file_name, self.file_name)) def edit_file(self):