Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
7335 Zobrazení

i to all,

how to round 2 decimals, even if the value are 00

example : 12.00 

can i do this on python

regards 

Avatar
Zrušit

We can achieve using python using help of "%.2f" format specifier. Can you explain more your requirement ? where you want to put 2 decimal ? i.e. inside any report or inside any web form etc...

Nejlepší odpověď

Python only displays what's needed, so it displated 10.0

If it's the matter of printing it as 10.00.

To do that.

>>> d = 10
>>> print "Value: %.2f" % float(d)
Value: 10.00
>>>

Hope this will help you.

Avatar
Zrušit
Autor

thanks Parikshit :)

Related Posts Odpovědi Zobrazení Aktivita
1
led 24
4381
1
srp 15
3078
2
bře 15
4355
1
bře 15
31661
1
bře 15
3760