Python获取本周指定的星期几

 https://www.cnblogs.com/iAmSoScArEd/p/16386216.html 我超怕的

 

获取本周星期一

import datetime

print(datetime.date.today()-datetime.timedelta(days=datetime.date.today().weekday()))

获取本周星期二

import datetime

print(datetime.date.today()-datetime.timedelta(days=datetime.date.today().weekday()-1))

获取本周星期三

import datetime

print(datetime.date.today()-datetime.timedelta(days=datetime.date.today().weekday()-2))

 

后面以此类推

posted @ 2022-06-17 16:32  我超怕的  阅读(498)  评论(0编辑  收藏  举报