gpt4 book ai didi

python - 如何用任何小数舍入一个值

转载 作者:行者123 更新时间:2023-12-05 08:17:37 24 4
gpt4 key购买 nike

无论值是什么,我都想让值总是四舍五入,例如:

Strength = 16.33333

我会用什么来使它(无论它等于什么)四舍五入到下一个整数?

最佳答案

只需使用ceil函数:

>>> import math
>>> a = math.ceil(16.33333)
>>> a
17
>>> a = math.ceil(17)
>>> a
17

关于python - 如何用任何小数舍入一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24047526/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com