from decimal import Decimal
# .2f设置小数位精确位数, 如下返回2.55
q = 2.551
t = format(Decimal(q), '.2f')
#向上取2位小数, 返回2.56
q = 2.551
t = format(Decimal( q + 0.005), '.2f')
from decimal import Decimal
# .2f设置小数位精确位数, 如下返回2.55
q = 2.551
t = format(Decimal(q), '.2f')
#向上取2位小数, 返回2.56
q = 2.551
t = format(Decimal( q + 0.005), '.2f')