Python Get Day Name from Number Example

By Hardik Savani October 30, 2023 Category : Python

In this post, we will learn python get day name from number. I would like to share with you python get day name from date. I would like to show you python calendar get day name. I explained simply step by step python number to day name.

In this example, I will give two examples for you of how to get the day name from number in python. therefore, let's see below example code and try it.

Example 1:

main.py

import calendar
  
dayNumber = 0
  
dayName = calendar.day_name[dayNumber]
  
print("Day Name : " + str(dayName))

Output:

Day Name : Monday

Example 2:

main.py

from datetime import date
  
currentDate = date.today()
  
longName = currentDate.strftime('%A')
print("Long Day Name : " + longName)
  
shortName = currentDate.strftime('%a')
print("Short Day Name : " + shortName)

Output:

Long Day Name : Wednesday
Short Day Name : Wed

I hope it can help you...

Tags :
Shares