تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
7395 أدوات العرض

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
يناير 24
4467
1
أغسطس 15
3128
2
مارس 15
4450
1
مارس 15
31733
1
مارس 15
3807