【Python】如何用decimal模块限制数据总位数
#将float类型转化成有固定总位数的数值。
from decimal import *
getcontext().prec=5
Decimal('107.23')/Decimal('0.9726')
a=str(Decimal('107.23')/Decimal('0.9726'))
#将float类型转化成有固定总位数的数值。
from decimal import *
getcontext().prec=5
Decimal('107.23')/Decimal('0.9726')
a=str(Decimal('107.23')/Decimal('0.9726'))