4

在 Python 2.x 上获取当前 Windows(或 OSX)区域设置 ID 的方法是什么。我想得到一个 int(或 str),它告诉操作系统中哪种语言处于活动状态。

不使用 WinAPI 可以吗?

4

1 回答 1

12

这是与Python 2.6中的locale模块相关的文档。

更具体地说,这是一个如何获取系统语言环境的示例(来自上面的链接):

import locale
loc = locale.getlocale() # get current locale
locale.getdefaultlocale() # Tries to determine the default locale settings and returns them as a tuple of the form (language code, encoding); e.g, ('en_US', 'UTF-8').
于 2013-10-15T17:27:15.007 回答