用途
locale.format():
>>> import locale>>> locale.setlocale(locale.LC_ALL, 'German')'German_Germany.1252'>>> print(locale.format('%.2f', 32757121.33, True))32.757.121,33您可以将语言环境更改限制为仅显示数值(使用
locale.format()时
locale.str()等),并使其他语言环境设置不受影响:
>>> locale.setlocale(locale.LC_NUMERIC, 'English')'English_United States.1252'>>> print(locale.format('%.2f', 32757121.33, True))32,757,121.33>>> locale.setlocale(locale.LC_NUMERIC, 'German')'German_Germany.1252'>>> print(locale.format('%.2f', 32757121.33, True))32.757.121,33


