Adapting number thousand separator to your local system

If you are in Italy you separate thousands in numbers with ‘.’.

For great numbers, the separation of digits is very useful, so here is the code to do it

>>> import locale
>>> locale.setlocale(locale.LC_ALL,"")
'Italian_Italy.1252'
>>> f"{1000:n}"
'1.000'

 

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.