Last active
May 31, 2019 07:04
-
-
Save zhyq0826/5873700 to your computer and use it in GitHub Desktop.
python 根据根据日期计算所在周的开始和结束
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
def get_week(): | |
today = datetime.date.today() | |
month = today.month | |
year = today.year | |
day = today.day | |
weekday = today.weekday() | |
start = today + datetime.timedelta(0-weekday) | |
end = today + datetime.timedelta(6-weekday) | |
start = datetime.datetime(start.year,start.month,start.day) | |
end = datetime.datetime(start.year,start.month,start.day) | |
return start, end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
老铁,你这是大意失荆州啊
end = datetime.datetime(end.year,end.month,end.day)