Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
7746 Visualizzazioni

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
Abbandona

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...

Risposta migliore

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
Abbandona
Autore

thanks Parikshit :)

Post correlati Risposte Visualizzazioni Attività
1
gen 24
4841
1
ago 15
3558
2
mar 15
4859
1
mar 15
32215
1
mar 15
4045