How can I convert an abbreviated month anme e.g. Apr
in python to the full name?
Method #1 : Using strftime() + %B In this, we use strftime() which converts date object to a string using a format, and by providing %B, it's enforced to just return a Month Name.
Use strftime() function of a datetime class For example, the %d-%m-%Y %H:%M:%S codes convert date to dd-mm-yyyy hh:mm:ss format.
Passing "%b" to strftime returns abbreviated month name while using "%B" returns full month 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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With