You can use the strftime
method of datetime object to get the name of the current month. Here's an example:
main.py108 chars5 lines
This will output the name of the current month as a string, such as "January", "February", etc.
The %B
is a formatting directive that tells strftime
to substitute the full name of the month. If you want to get the abbreviated name (e.g. "Jan", "Feb"), use %b
instead.
gistlibby LogSnag