1、向上取整

  • import math
  • >>> math.ceil(4.12)
  • 5

2、向下取整

  • import math
  • >>> math.floor(4.12)
  • 4

3、四舍五入

  • >>> round(2.3)
  • 2
  • >>> round(2.6)
  • 3

 

math模块其他用法:https://www.cnblogs.com/xiaoyh/p/9791670.html

相关文章:

  • 2022-12-23
  • 2021-08-17
  • 2021-12-27
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2023-01-31
  • 2022-01-16
相关资源
相似解决方案