获取系统encodeing

Wensheng <[email protected]>
reply-to        [email protected]
to      python-cn`CPyUG`华蟒用户组 <[email protected]>
date    Sat, May 24, 2008 at 7:51 AM
subject [CPyUG:52309] Re: python 如何取得操作系统的默认的encoding

   1 import locale
   2 locale.getdefaultlocale()

在windows和linux都可以。我用的是英文xp, 但我设的中文locale, 所以得到的是 ('en_US','cp936')

cp936 就是 gbk

另外可用

import win32api
win32api.GetSystemDefaultLCID()

但得到的是Id, 你得有转换表才行。


反馈

创建 by -- ZoomQuiet [2008-05-23 23:54:28]

MiscItems/2008-05-23 (last edited 2009-12-25 07:16:01 by localhost)