Get Day name from Weekday int

后端 未结 8 1136
梦如初夏
梦如初夏 2020-12-14 05:14

I have a weekday integer (0,1,2...) and I need to get the day name (\'Monday\', \'Tuesday\',...).

Is there a built in Python function or way of doing this?

H

8条回答
  •  悲哀的现实
    2020-12-14 06:04

    You can use built in functions for that for ex suppose you have to find day according to the specific date.

    import calendar
    
    month,day,year = 9,19,1995
    ans =calendar.weekday(year,month,day)
    
    print(calendar.day_name[ans])
    

    calendar.weekday(year, month, day) - Returns the day of the week (0 is Monday) for year (1970–…), month (1–12), day (1–31).

    calendar.day_name - An array that represents the days of the week in the current locale

    for more reference -https://docs.python.org/2/library/calendar.html#calendar.weekday

提交回复
热议问题