将浮点数舍入为python中的下一个整数

时间:2019-01-09 12:59:01

标签: python

我想将浮点值转换为下一个整数,例如

x=1.1
print(x)

应返回2

,它也等于1.9到2。

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:1)

import math
math.ceil(1.1)
# 2

答案 1 :(得分:1)

import math
x=1.1
print(math.ceil(x))
# 2
相关问题