跳至内容
菜单
此问题已终结
2 回复
7383 查看

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
4418
1
8月 15
3114
2
3月 15
4396
1
3月 15
31705
1
3月 15
3780