编程语言
首页 > 编程语言> > 制作打卡表-列出周六周日-Python

制作打卡表-列出周六周日-Python

作者:互联网

for y in [2020, 2021]:
    for m in range(1,13):
        for day in range(1, 32):
            try:
                d = datetime.date(y,m,day)
            except: 
                pass
            if d.weekday() == 5:
                print(d.strftime('%Y-%m-%d, 星期六'))
            elif d.weekday() == 6:
                print(d.strftime('%Y-%m-%d, 星期日'))

标签:-%,Python,range,weekday,print,打卡,day,strftime,周日
来源: https://blog.csdn.net/ManWZD/article/details/121047446