1,通过传入这一年的第几周,获取那一周,周一到周末的日期
from isoweek import Week monday = Week(int(year), int(week)).monday() # 当前周的周一
sunday = Week(int(year), int(week)).sunday() # 当前周的周日
2,传入时间,获取今天是周几
from datetime import datetime now = datetime.now() now.weekday()
==> 4 # 实际是周5, 数值会比较小一点
3,传入年月日,获取当前是第几周和周几
import datetime datetime.date(2019,5,24).isocalendar() ==>(2019, 21, 5) # 年,第几周,星期几