跨平台使用set locale [英] cross platform use of set locale

查看:56
本文介绍了跨平台使用set locale的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置我的语言环境,这样当我输出一个数字时,它的格式是数千个分组的格式。我发现的问题是那里

似乎不是非常好的跨平台支持语言环境,甚至

之间的unix''它''可怕的。

hi there i need to set my locale so that when i output a number it''s
formatted with thousands grouped. the problem i''ve found is there
doesn''t seem to be very good cross platform support for locales, even
between unix''s it''s horrid.

推荐答案

在< ma *********************** **************@python.or g> ;, Timothy Smith

写道:
In <ma*************************************@python.or g>, Timothy Smith
wrote:
嗨我需要设置我的语言环境,这样当我输出一个数字时,它的格式是数千个分组。我发现的问题是
对于语言环境来说似乎不是非常好的跨平台支持,甚至在unix'之间它是可怕的。
hi there i need to set my locale so that when i output a number it''s
formatted with thousands grouped. the problem i''ve found is there
doesn''t seem to be very good cross platform support for locales, even
between unix''s it''s horrid.




你试过这个::


导入语言环境

locale

locale.setlocale (LC_ALL,'''')

locale.format(''%。2f'',1000000,True)


真实开启分组。应该跨平台工作。


Ciao,

Marc''BlackJack''Rintsch



Have you tried this::

import locale
locale
locale.setlocale(LC_ALL, '''')
locale.format(''%.2f'', 1000000, True)

The `True` turns on grouping. Should work cross platform.

Ciao,
Marc ''BlackJack'' Rintsch


Marc ''BlackJack''Rintsch写道:
Marc ''BlackJack'' Rintsch wrote:
< ma ************************** ***********@python.or g> ;,蒂莫西史密斯
写道:
In <ma*************************************@python.or g>, Timothy Smith
wrote:
我需要设置我的语言环境,以便当我输出一个数字,它被格式化为数千个分组。我发现的问题是那里似乎并不是非常好的跨平台支持语言环境,甚至在unix'之间它是可怕的。
hi there i need to set my locale so that when i output a number it''s
formatted with thousands grouped. the problem i''ve found is there
doesn''t seem to be very good cross platform support for locales, even
between unix''s it''s horrid.



你试过这个::

导入语言环境
locale
locale.setlocale(LC_ALL,'''')
locale.format(''%。2f'',1000000,True)

`True`打开分组。应该跨平台工作。

Ciao,
Marc''BlackJack''Rintsch



Have you tried this::

import locale
locale
locale.setlocale(LC_ALL, '''')
locale.format(''%.2f'', 1000000, True)

The `True` turns on grouping. Should work cross platform.

Ciao,
Marc ''BlackJack'' Rintsch



没关系,但我怎么弄用a,?

分组成千上万,这就意味着我必须通过格式化程序运行所有内容

才能显示它:/它会是更好,如果我可以选择一个合适的

语言环境


thats ok, but how do i get it to group thousands with a , ?
and thats would mean i''d have to run everything through a formatter
before i displayed it :/ it''d be nicer if i could just select a proper
locale


在< ma ************** ***********************@python.or g> ;,蒂莫西史密斯

写道:
In <ma*************************************@python.or g>, Timothy Smith
wrote:
我需要设置我的语言环境,这样当我输出一个数字时,它的格式是数千个分组。 [a?|]
hi there i need to set my locale so that when i output a number it''s
formatted with thousands grouped. [a?|]



导入区域设置
locale
locale.setlocale(LC_ALL,'''')
locale.format(''% .2f'',1000000,True)

`True`打开分组。应该跨平台工作。



import locale
locale
locale.setlocale(LC_ALL, '''')
locale.format(''%.2f'', 1000000, True)

The `True` turns on grouping. Should work cross platform.



没关系,但是如何让它成千上万用?并且那将意味着我必须在我显示它之前通过格式化程序运行所有内容:/它会更好,如果我可以选择适当的区域设置



thats ok, but how do i get it to group thousands with a , ? and thats
would mean i''d have to run everything through a formatter before i
displayed it :/ it''d be nicer if i could just select a proper locale




它使用系统的语言环境。如果* your *系统语言环境已配置

使用'',''作为分组的分隔符,那么它应该由

`locale.format()`使用。


Ciao,

Marc''BlackJack''Rintsch



It uses the locale of the system. If *your* systems locale is configured
to use '','' as separator for grouping, then it should be used by
`locale.format()`.

Ciao,
Marc ''BlackJack'' Rintsch


这篇关于跨平台使用set locale的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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