>>>month_list=['January','February','March','April','May','June',
...'July','August','September','October','November','December']

This is somehow completely on the collective farm.
Are there better options?
  • This collective farm option is the easiest. The alternative is to use something like pymorphy2 or PyICU for declensions. – Ashamed Anteater Feb 3 '19 at 11:04
  • Ashamed Anteater, thank you. – Chinese Paintball Feb 4 '19 at 09:17

2 Answers 2

>>>locale.setlocale(locale.LC_TIME,'en_US.UTF-8')
'en_US.UTF-8'
>>>datetime.now()
datetime.datetime(2019, 2, 3, 12, 44, 19, 396804)
>>>datetime.now().strftime('% B')
'February'

strftime.org
  • and I wrote'February', not'February' – Blue-eyed Butterfly Feb 3 '19 at 10:54
  • It's just February, without a case.
    >>>import locale
    >>>locale.setlocale (locale.LC_TIME,'en_US.UTF-8')
    'en_RU.UTF -8'

    gt;>from datetime import datetime

    >>datetime.now(). Strftime ('% B')
    'February'
    >>;>
    – Chinese Paintball Feb 3 '19 at 10:56
  • In general, Windows only works in
    locale.setlocale (locale.LC_ALL,'')
    and displays"February."
    – Depressing23 Feb 3 '19 at 11:34
  • Depressing23, not only. On Windows, just another locale name is locale.setlocale (locale.LC_TIME,'Russian_Russia') – Ashamed Anteater Feb 4 '19 at 09:27
As far as I remember, the standard library can only"January".You can see how this is done in django(there definitely is'January'and most likely done by writing a translation for each language via gettext).
Shl, pytils seems to be able to incline