Calendar: day/month names in specific locale

后端 未结 3 1948
甜味超标
甜味超标 2020-12-17 10:03

I am playing with Python\'s calendar module that\'s in the standard library. Basically I need a list of all days of a month, like so:

>>> import cal         


        
3条回答
  •  醉梦人生
    2020-12-17 10:33

    Ha! Found an easy way to get localized day/month names:

    >>> import locale
    >>> locale.setlocale(locale.LC_ALL, 'de_DE')
    'de_DE'
    >>> import calendar
    >>> calendar.month_name[10]
    'Oktober'
    >>> calendar.day_name[1]
    'Dienstag'
    

提交回复
热议问题