Convert python abbreviated month name to full name
If you insist on using datetime
as per your tags, you can convert the short version of the month to a datetime object, then reformat it with the full name:
import datetime
datetime.datetime.strptime('apr','%b').strftime('%B')
a simple dictionary would work
eg
month_dict = {"jan" : "January", "feb" : "February" .... }
month_dict["jan"]
'January'
import calendar
months_dict = dict(zip(calendar.month_abbr[1:], calendar.month_name[1:]))
# {'Jan': 'January', 'Feb': 'February', 'Mar': 'March', 'Apr': 'April', 'May': 'May', 'Jun': 'June', 'Jul': 'July', 'Aug': 'August', 'Sep': 'September', 'Oct': 'October', 'Nov': 'November', 'Dec': 'December'}
Make sure you convert to proper cases based on your need.
Similarly, calendar library also has calendar.day_abbr
and calendar.day_name
Here is a method to use calendar library.
>>> import calendar
>>> calendar.month_name [list(calendar.month_abbr).index('Apr')]
'April'
>>>