如何在Windows上设置Python默认语言环境?

如何在Windows上设置Python默认语言环境?

问题描述:

我知道我使用更改了应用程序的语言环境

I know I change change the locale for an application using

import locale
locale.setlocale(locale.LC_ALL, '')

文档显示语言环境的默认值通常来自LANG环境变量.但是,在Windows平台上,似乎有所不同. Python在哪里使用区域设置的默认值?有没有办法更改我所有Python脚本的默认值?

Documentation says default value for locale usually comes from LANG environment variable. However, on Windows platform, it seems to be different. Where does Python takes the default value for locale? Is there a way to change this default value for all my Python scripts?

可以通过控制面板设置Windows系统的默认系统区域设置.当您使用''作为第二个参数调用setlocale时,Python使用此默认语言环境. 有关如何更改默认语言环境的信息,请参见此处.

The default system locale for a windows system can be set via the control panel. Python uses this default locale when you call setlocale with '' as the second argument. See here on how to change the default locale.