I got a problem in string format function which I don't understand. Please help to explain why and how to fix this. thanks. ( python 2.7.3 , [GCC 4.6.3] on linux2 , ubuntu 12.04 x86 )
>>> import locale
>>> locale.format("%0.{0}f".format(2), 1.135, grouping=True)
'1.14'
>>> locale.format("%0.{0}f".format(2), 1.125, grouping=True)
'1.12'
>>> ("%0.2f")%(1.135)
'1.14'
>>> ("%0.2f")%(1.125)
'1.12'
I need the format result to match the round() function
>>> round(1.135, 2)
1.14
>>> round(1.125, 2)
1.13
Thank everyone.