Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
a = 6 b = 2 c = 9 print(c/b//b)
谁能告诉为什么这个 2.0 而不是 2 的结果?9/2 = 4.5 4.5//2 应该是 2 bcos 地板除法四舍五入到最接近的整数值。但为什么结果是 2.0?
楼层除法给出四舍五入值。但它不一定给出整数。所以它取决于操作数的类型,因为 4.5 是一个浮点值,因此答案必须是一个浮点数。这就是为什么 4//2 = 2 和 4.5//2 = 2.0