Python Get Month Name from Number Example
In this tutorial, I will show you python get month name from number. Here you will learn python calendar get month name from number. you will learn how to get month name from number in python. you'll learn python3 find month name from number.
In this example, I will give two examples for you of how to get the month name from number in python. therefore, let's see below example code and try it.
Example 1: using datetime
import datetime monthNumber = "7" dateTimeObject = datetime.datetime.strptime(monthNumber, "%m") monthName = dateTimeObject.strftime("%b") print("Month Short Name: ", monthName) fullMonthName = dateTimeObject.strftime("%B") print("Month Full Name: ", fullMonthName)
Month Short Name: Jul Month Full Name: July
Example 2: using calendar
import calendar monthNumber = 7 res = calendar.month_name[monthNumber] print("Month Name : " + str(res))
Month Name : July
I hope it can help you...
We are Recommending you
- How to Get Tomorrow Date in Python?
- How to Get Current Second in Python?
- How to Get Current Minute in Python?
- How to Get Current Hour in Python?
- How to Get Current Time in Python?
- How to Get Current Month in Python?
- How to Get Current Day in Python?
- How to Get Current Year in Python?
- How to Get Current Date and Time in Python?
- How to Get Current Date in Python?