わいえむねっと

Contents
Categories
Calendar
2010/06
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Monthly Archives
~2000/01
Recent Entries
RSS1.0
Templates
Information
Processed: 0.054 sec
Chashed: -
2010/06/11 Fri
Pythonのlocale関連の続き。
setlocaleしたら %Y/%m/%d になった。環境変数を参照してくれるわけではないのか。
でも、 %Y年%m月%d日 になる場合もあるので、なんにせよ日本語ロケールでは %x はイマイチな気がする。

from datetime import date
import locale

print locale.getdefaultlocale()

print locale.getlocale(locale.LC_TIME)
print date.today().strftime('%x')

locale.setlocale(locale.LC_TIME, 'ja_JP.UTF-8')

print locale.getlocale(locale.LC_TIME)
print date.today().strftime('%x')

  • FreeBSD 8.0 + Python 2.6.2
(None, None)
(None, None)
06/11/10
('ja_JP', 'UTF-8')
2010/06/11

  • Fedora Core 6 + Python 2.4.3
('ja_JP', 'utf')
(None, None)
06/11/10
('ja_JP', 'utf')
2010年06月11日