How can I get the month name from the month number?
For instance, if I have
3, I want to return
How to get the string
From that you can see that
calendar.month_name would return
March, and the array index of
0 is the empty string, so there's no need to worry about zero-indexing either.
import datetime mydate = datetime.datetime.now() mydate.strftime("%B")
Some more info on the Python doc website
[EDIT : great comment from @GiriB] You can also use
%b which returns the short notation for month name.
For the example above, it would return