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')

相关文章:

  • 2022-12-23
  • 2022-01-05
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-08
  • 2021-09-01
  • 2022-12-23
  • 2021-12-24
相关资源
相似解决方案