gpt4 book ai didi

python - 截断小数点后的所有数字

转载 作者:行者123 更新时间:2023-12-04 04:53:29 24 4
gpt4 key购买 nike

在Python 3中,如何截断小数点后的所有数字?

例如,将3.444截短为3。

最佳答案

通过将其转换为int:

>>> num = 3.444
>>> int(num)
3

关于python - 截断小数点后的所有数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14539186/

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