Reputation: 197
I found that if I use round function to some float values, it is OK to round to two decimals, but sometimes, for example, round(myvalu, 2)
it will return 1.2
instead of 1.20
, but actually I want every returned value is rounded to two decimals, i.e. 1.20
instead of 1.2
. What should I do?
Upvotes: 0
Views: 1011
Reputation: 5225
That's something you'd do when displaying the number.
Try
'%.2f' % num
Upvotes: 1