gpt4 book ai didi

Python 3 整数除法

转载 作者:IT老高 更新时间:2023-10-28 21:04:53 29 4
gpt4 key购买 nike

在 Python 3 与 Python 2.6 中,我注意到我可以将两个整数相除并得到一个 float 。如何恢复 Python 2.6 的行为?

是否有不同的方法来获取 int/int = int?

最佳答案

试试这个:

a = 1
b = 2
int_div = a // b

关于Python 3 整数除法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19507808/

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