I am trying to print an integer in Python 2.6.1 with commas as thousands separators. For example, I want to show the number 1234567
as 1,234,567
. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.
It does not need to be locale-specific to decide between periods and commas. I would prefer something as simple as reasonably possible.
Here is another variant using a generator function that works for integers:
And here's a test:
Italian numbers: thousand separator is a '.'
I solved it this way... for a dictonary
out: le immobilizzazioni valgono 419.168 €. i debiti per TFR sono pari a 13.255 €. l’attivo circolante è di 195.443 euro. il fondo rischi ed oneri ha un importo pari a 13.374 euro. i debiti sono 180.947 €. i ratei e risconti attivi sono pari a 2.271 euro. i ratei e risconti passivi sono pari a 1.864 euro. I crediti verso i soci sono pari a 17.630 euro.