Python 3.x rounding behavior

前端 未结 11 1703
别那么骄傲
别那么骄傲 2020-11-22 00:41

I was just re-reading What’s New In Python 3.0 and it states:

The round() function rounding strategy and return type have changed. Exact halfway cas

11条回答
  •  误落风尘
    2020-11-22 01:07

    You can control the rounding you using the math.ceil module:

    import math
    print(math.ceil(2.5))
    > 3
    

提交回复
热议问题