如何在Windows上设置Python默认语言环境? [英] How to set Python default locale on Windows?

查看:169
本文介绍了如何在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.

这篇关于如何在Windows上设置Python默认语言环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆