每周跑一下Python脚本,轻松生成工作日志模板

2021/6/1 20:23:02

本文主要是介绍每周跑一下Python脚本,轻松生成工作日志模板,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

需求:

1.因为有要记录每天工作日志的需求,为了方便就写了个日志模板

2.已经实现打包,每周一 只需要跑一下脚本就行

3.其他需求同理

本人python学习萌新-这里贴一下一期版本源码-仅供学习-勿喷!

本人联系方式-微信:wvqusrtg

 一期版本源码-仅供学习:

import sys
import datetime


# 创建一个txt文件,文件名为mytxtfile
def text_create(name, path):
    desktop_path = path
    # 新创建的txt文件的存放路径
    full_path = desktop_path + name + '.txt'  # 也可以创建一个.doc的word文档
    file = open(full_path, 'w')
    filename = name
    # text_create(filename)
    output = sys.stdout
    outputfile = open(path + filename + '.txt', 'w')
    sys.stdout = outputfile

    for i in range(0, 7):
        timeStr = (datetime.datetime.now() + datetime.timedelta(days=i)).strftime("%Y-%m-%d %A")
        print('---------', timeStr, '---------', file=outputfile)
        print('---AM:', file=outputfile)
        print('项目:收单App 工作内容:收单App', file=outputfile)
        print('1.', file=outputfile)
        print('2.\n', file=outputfile)

        print('---PM:', file=outputfile)
        print('项目:收单App 工作内容:收单App', file=outputfile)
        print('1.', file=outputfile)
        print('2.\n', file=outputfile)

        print('---Night:', file=outputfile)
        print('项目:收单App 工作内容:收单App', file=outputfile)
        print('1.', file=outputfile)
        print('2.\n', file=outputfile)
    # close后才能看到写入的数据
    outputfile.close()


# print(datetime.datetime.now().strftime("%Y-%m-%d %A"))

begin = datetime.datetime.now().strftime("%Y-%m-%d")
end = (datetime.datetime.now() + datetime.timedelta(days=7)).strftime("%Y-%m-%d")
# print(begin, end)
print(f'---用途:生成工作日志模板')

target = f'{begin}---{end} 工作日志'
print(f'---生成文件标题如下: \n{target}.txt')

path = '/Users/nixinsheng/Documents/python3/PyCharm_HelloWorld/Demo20210201/'
print(f'---生成文件路径如下: \n{path}')

text_create(target, path)

 



这篇关于每周跑一下Python脚本,轻松生成工作日志模板的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程