跳至內容
選單
此問題已被標幟
2 回覆
7398 瀏覽次數

i to all,

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

example : 12.00 

can i do this on python

regards 

頭像
捨棄

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

最佳答案

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.

頭像
捨棄
作者

thanks Parikshit :)

相關帖文 回覆 瀏覽次數 活動
1
1月 24
4474
1
8月 15
3138
2
3月 15
4457
1
3月 15
31734
1
3月 15
3813