打印周报模板

Posted xuehuiping

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了打印周报模板相关的知识,希望对你有一定的参考价值。

每次都整理周报,真麻烦,搞个工具吧~
打印的格式是md格式,不知道后续编辑方便不?


import calendar
import datetime


def print_work_report_weekly(year):
    c = calendar.TextCalendar(firstweekday=0)
    week = 0
    week_end = False
    months = [n for n in range(1, 12 + 1)]
    for month in months:
        results = c.itermonthdays(year, month)
        start = datetime.datetime(year, month, 1)
        for result in results:
            end = None
            # 是正常的日期
            if result > 0:
                day = result
                date = datetime.date(year, month, day)
                n = date.weekday()
                if n == 0:
                    start = date
                elif n == 4 and not end:
                    end = date
                    week_end = True
                if week_end and (start or end):
                    week += 1
                    print("第{}周 ({}-{})".format(week, start.strftime("%m.%d"), end.strftime("%m.%d")))
                    week_end = False


print_work_report_weekly(2019)

打印结果

第1周 (01.01-01.04)
第2周 (01.07-01.11)
第3周 (01.14-01.18)
第4周 (01.21-01.25)
第5周 (02.01-02.01)
第6周 (02.04-02.08)
第7周 (02.11-02.15)
第8周 (02.18-02.22)
第9周 (03.01-03.01)
第10周 (03.04-03.08)
第11周 (03.11-03.15)
第12周 (03.18-03.22)
第13周 (03.25-03.29)
第14周 (04.01-04.05)
第15周 (04.08-04.12)
第16周 (04.15-04.19)
第17周 (04.22-04.26)
第18周 (05.01-05.03)
第19周 (05.06-05.10)
第20周 (05.13-05.17)
第21周 (05.20-05.24)
第22周 (05.27-05.31)
第23周 (06.03-06.07)
第24周 (06.10-06.14)
第25周 (06.17-06.21)
第26周 (06.24-06.28)
第27周 (07.01-07.05)
第28周 (07.08-07.12)
第29周 (07.15-07.19)
第30周 (07.22-07.26)
第31周 (08.01-08.02)
第32周 (08.05-08.09)
第33周 (08.12-08.16)
第34周 (08.19-08.23)
第35周 (08.26-08.30)
第36周 (09.02-09.06)
第37周 (09.09-09.13)
第38周 (09.16-09.20)
第39周 (09.23-09.27)
第40周 (10.01-10.04)
第41周 (10.07-10.11)
第42周 (10.14-10.18)
第43周 (10.21-10.25)
第44周 (11.01-11.01)
第45周 (11.04-11.08)
第46周 (11.11-11.15)
第47周 (11.18-11.22)
第48周 (11.25-11.29)
第49周 (12.02-12.06)
第50周 (12.09-12.13)
第51周 (12.16-12.20)
第52周 (12.23-12.27)

以上是关于打印周报模板的主要内容,如果未能解决你的问题,请参考以下文章

周报月报有多折磨人?万能报表模板建议收藏!(附模板)

测试部门工作周报模板

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段1——vue主模板

VSCode自定义代码片段2——.vue文件的模板

VSCode自定义代码片段(vue主模板)