Using the lib Decimal
i can set the quantize
to get the 2 decimal places with zero:
from decimal import Decimal
value = Decimal('1000.0').quantize(Decimal('1.00'))
print(value) # Decimal('1000.00')
But if i need to change it to float
the last zero disappear:
value = float(value)
print(value) # 1000.0
How can i set two zeros at decimal place and still use as float?
the print
method was an e example to show the final result, i need to use the value
as float
and not string
.
the value will be used in a json request:
{
"value": 1000.00
}