Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40813
| Date | 2013-03-07 14:06 -0500 |
|---|---|
| From | John Posner <jjposner@optimum.net> |
| Subject | Re: Insert comma in number? |
| References | <mailman.15214.1362647403.2938.python-list@python.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3047.1362684983.2939.python-list@python.org> (permalink) |
Peter Otten wrote: > Last not least there's the option to employ locale-aware formatting: Not quite last ... there's the mind-bending regular expression route: import re re.sub(r"(?<=\d)(?=(\d\d\d)+$)", ",", "12345678") # 12,345,678 re.sub(r"(?<=\d)(?=(\d\d\d)+$)", ",", "-54321") # -54,321 -John
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Insert comma in number? John Posner <jjposner@optimum.net> - 2013-03-07 14:06 -0500
csiph-web