Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
7355 Widoki

i to all,

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

example : 12.00 

can i do this on python

regards 

Awatar
Odrzuć

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

Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

thanks Parikshit :)

Powiązane posty Odpowiedzi Widoki Czynność
1
sty 24
4401
1
sie 15
3096
2
mar 15
4373
1
mar 15
31685
1
mar 15
3768