İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
7860 Görünümler

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
Vazgeç

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

En İyi Yanıt

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
Vazgeç
Üretici

thanks Parikshit :)

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Oca 24
4964
1
Ağu 15
3718
2
Mar 15
5029
1
Mar 15
32428
1
Mar 15
4158