这个问题使我丧命。如何在Python中向上取整?
我尝试了四舍五入(数字),但它四舍五入数字。例:
round(2.3) = 2.0 and not 3, what I would like
我尝试了int(number + .5),但是它再次将数字取整!例:
int(2.3 + .5) = 2
然后我尝试了round(number + .5),但是在边缘情况下不起作用。例:
WAIT! THIS WORKED!
请指教。
import math print(math.ceil(4.2))