I want to find out the following:
given a date (datetime
object), what is the corresponding day of the week.
For instance Sunday is the first day, Monday: second day.. and so on
And then if the input is something like today's date.
Example
>>> today = datetime.datetime(2017, 10, 20)
>>> today.get_weekday() # what I look for
The output is maybe 6
(since its Friday)
I solved this for a codechef question.
If you'd like to have the date in English:
Read more: https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior
To get Sunday as 1 through Saturday as 7, this is the simplest solution to your question:
All of them:
Output: