add func:若已经存在同名文档,则不执行
This commit is contained in:
parent
87e00cdfcb
commit
dbec37fad5
26
ReadMe.md
Normal file
26
ReadMe.md
Normal file
@ -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
|
||||
```
|
@ -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 = ""
|
||||
@ -21,6 +22,10 @@ class WEEK_REPORT:
|
||||
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))
|
||||
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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user