Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40719
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Insert comma in number? |
| Date | 2013-03-07 09:58 +0100 |
| Organization | None |
| References | <9c8df3b5-510a-4d00-a3ff-0c59799dcded@googlegroups.com> <kh9h53$r38$1@ger.gmane.org> <CAK38ikRVMhjFEgh_KKQzLBQ0Pp9rQRc-Nvs_OTk+vVRy4HRU9A@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2988.1362646692.2939.python-list@python.org> (permalink) |
Paul Volkov wrote:
> 2013/3/7 Peter Otten <__peter__@web.de>:
>> Last not least there's the option to employ locale-aware formatting:
>>
>>>>> import locale
>>>>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
>> 'en_US.UTF-8'
>>>>> locale.format("%d", 12345, grouping=True)
>> '12,345'
>>
>> In German usage of "." and "," is reversed, so:
>>
>>>>> locale.setlocale(locale.LC_ALL, "de_DE.UTF-8")
>> 'de_DE.UTF-8'
>>>>> locale.format("%d", 12345, grouping=True)
>> '12.345'
>
> Does this locale-aware example only work on UNIX?
If you have Windows in mind: I don't know what it takes to get multiple
locales on a Windows system, but for the default locale that you can specify
with
locale.setlocale(locale.LC_ALL, "")
it should work.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Insert comma in number? eli m <techgeek201@gmail.com> - 2013-03-06 15:39 -0800 Re: Insert comma in number? ian douglas <iandouglas736@gmail.com> - 2013-03-06 15:51 -0800 Re: Insert comma in number? Chris Rebert <clp2@rebertia.com> - 2013-03-06 16:07 -0800 Re: Insert comma in number? Terry Reedy <tjreedy@udel.edu> - 2013-03-06 20:28 -0500 Re: Insert comma in number? Peter Otten <__peter__@web.de> - 2013-03-07 08:55 +0100 Re: Insert comma in number? Paul Volkov <capt-obvious@yandex.ru> - 2013-03-07 12:30 +0400 Re: Insert comma in number? Peter Otten <__peter__@web.de> - 2013-03-07 09:58 +0100
csiph-web