返回一天在這周的週一和週日

import datetimeget

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, sundayimport

print(get_current_week())date



做者:yc12192057
連接:https://www.jianshu.com/p/b6567c4db86f

im

相關文章
相關標籤/搜索