How to format a number?

C

Clodoaldo

I want to format a number with thousands separator to the 'pt_br'
locale.

I'm trying like this:
import locale
locale.setlocale(locale.LC_ALL, ('pt_br', 'ascii')) 'pt_BR.ISO8859-1'
locale.format('%d', 9876, True) '9876'
locale.localeconv()['thousands_sep'] ''
locale.localeconv()['mon_thousands_sep']
'.'

The thousands separator is defined only for the ['mon_thousands_sep']
key and not for the ['thousands_sep'] one. What should be done? Set the
['thousands_sep'] to '.' or somehow build the format string as a
monetary number? If any of the former, how?

Regards, Clodoaldo Pinto Neto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,145
Latest member
web3PRAgeency
Top