I want to have thousands of delimiters in floats. What am I doing:
>>> import locale >>> locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') 'en_US.UTF-8' >>> print '{0:n}'.format(123456.0) 123,456
If the integer part has 7 or more digits, it does not work:
>>> print '{0:n}'.format(1234567.0) 1.23457e+06
The workaround I found is to rotate the float to an integer before forming:
>>> print '{0:n}'.format(int(1234567.0)) 1,234,567
Is there a format string that would handle all floats without having to turn it into an integer first?
source share