How do I get the day of week given a date?

前端 未结 26 1419
迷失自我
迷失自我 2020-11-22 04:40

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

相关标签:
26条回答
  • 2020-11-22 05:30

    Using Canlendar Module

    import calendar
    a=calendar.weekday(year,month,day)
    days=["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY","SUNDAY"]
    print(days[a])
    
    0 讨论(0)
  • 2020-11-22 05:32

    here is how to convert a listof dates to date

    import datetime,time
    ls={'1/1/2007','1/2/2017'}
    dt=datetime.datetime.strptime(ls[1], "%m/%d/%Y")
    print(dt)
    print(dt.month)
    print(dt.year)
    
    0 讨论(0)
提交回复
热议问题