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
# 返回时间字符串
# return datetime.datetime.strftime(monday, "%Y/%m/%d") + ' 00:00:00+08:00', datetime.datetime.strftime(sunday, "%Y/%m/%d")+ ' 23:59:59+08:00'
print(get_current_week())
python获取当前周 周一和周末时间
最新推荐文章于 2024-11-29 06:00:00 发布