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

前端 未结 26 1469
迷失自我
迷失自我 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:12

    import datetime
    import calendar
    
    day, month, year = map(int, input().split())
    my_date = datetime.date(year, month, day)
    print(calendar.day_name[my_date.weekday()])
    

    Output Sample

    08 05 2015
    Friday
    

提交回复
热议问题