How to set Python default locale on Windows?

2019-04-02 04:19发布

问题:

I know I change change the locale for an application using

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

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?

回答1:

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.



回答2:

It is the value you've set in Control Panel.