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
main.py
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)
Output:
Month Short Name: Jul Month Full Name: July
Example 2: using calendar
main.py
import calendar monthNumber = 7 res = calendar.month_name[monthNumber] print("Month Name : " + str(res))
Output:
Month Name : July
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
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?