利用round(number[, ndigit] )函数四舍五入

 

保留浮点数的小数点。

     如保留小数点后两位。

     num = 9.2174

     new_num = round( num , 2 )

     则new_num = 9.22    (四舍五入)

 

>>> num = 4.93
>>> num
4.93
>>> new_num = round(num,0)
>>> new_num
5.0
>>> num = 4.49
>>> new_num = round(num,0)
>>> new_num
4.0
>>> new_num = round(num,0)

 

相关文章:

  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-09-16
  • 2021-12-25
相关资源
相似解决方案