python - a//b 和 int(a/b) 有什么区别?

标签 python python-3.x

对于较小的数字,它们似乎相等,但对于较大的数字,它们似乎不同。

例如:

a = int(1267650600228229401496703205376/10)
b = 1267650600228229401496703205376 // 10
print(a - b) # prints 7036874417767

a = int(1493845793475/10)
b = 1493845793475 // 10
print(a - b) # prints 0

怎么会?

最佳答案

作为对现有答案的补充,似乎值得一提的是您无需走那么远就能观察到差异:

>>> -1//2
-1
>>> int(-1/2)
0

关于python - a//b 和 int(a/b) 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42301498/

相关文章:

python - 在 django 中显示 'completed' 表单

python - 分配多索引列,同时保留索引级别值的顺序

python - 将一列时间戳转换为 pandas 中的句点

python-3.x - 仅对DatetimeIndex,TimedeltaIndex或PeriodIndex有效,但获得了 'Int64Index'的实例

python - 如何在Python中将文本文件分割成适当数量的列?

python - 在/tmp/pip_build_root/confluent-kafka 中安装失败,错误代码为 1

python - 对平面文件中的日期时间值求和

javascript - 使用 Python 从也包含非 JSON 声明的 .js 文件中提取 JSON?

python - 如何将文本放入输入行 : how to ask for user input on the command line while providing a 'default' answer that the user can edit or delete?

python - 使用字典的字典创建命名空间