gpt4 book ai didi

Python3.3 舍入

转载 作者:行者123 更新时间:2023-11-28 19:37:15 28 4
gpt4 key购买 nike

在 Python 中,我想将两个数字相除,如果答案不是整数,我希望将数字四舍五入为上面的数字。
例如 100/30 不是给 33.3 而是给 4。谁能建议如何做到这一点?谢谢。

最佳答案

您可以使用 math.ceil()功能:

>>> import math
>>> math.ceil(100/33)
4

关于Python3.3 舍入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20750297/

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