Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
7421 Weergaven

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
Annuleer

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

Beste antwoord

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
Annuleer
Auteur

thanks Parikshit :)

Gerelateerde posts Antwoorden Weergaven Activiteit
1
jan. 24
4485
1
aug. 15
3149
2
mrt. 15
4494
1
mrt. 15
31750
1
mrt. 15
3822