返回一天在这周的周一和周日

import datetime

def get_current_week():
monday, sunday = datetime.date.today(), datetime.date.today()
one_day = datetime.timedelta(days=1)
while monday.weekday() != 0:
monday -= one_day
while sunday.weekday() != 6:
sunday += one_day
# 返回当前的星期一和星期天的日期
return monday, sunday

print(get_current_week())



作者:yc12192057
链接:https://www.jianshu.com/p/b6567c4db86f

posted @ 2019-08-20 14:23  骨灰盒少女  阅读(209)  评论(0编辑  收藏  举报