Python中的区域设置日期格式

问题描述:

如何使用母语打印出 datetime.datetime.now()

    >>> session.deathDate.strftime("%a, %d %b %Y")
    'Fri, 12 Jun 2009'

我想得到相同的结果,但用本地语言。

I'd like to get the same result but in local language.

设置本例如:

>>> import time
>>> print time.strftime("%a, %d %b %Y %H:%M:%S")
Sun, 23 Oct 2005 20:38:56
>>> import locale
>>> locale.setlocale(locale.LC_TIME, "sv_SE") # swedish
'sv_SE'
>>> print time.strftime("%a, %d %b %Y %H:%M:%S")
sön, 23 okt 2005 20:39:15