Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
7435 Näkymät

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
Hylkää

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

Paras vastaus

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
Hylkää
Tekijä

thanks Parikshit :)

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
tammik. 24
4497
1
elok. 15
3171
2
maalisk. 15
4506
1
maalisk. 15
31779
1
maalisk. 15
3831