相关疑难解决方法(0)

Python中"round"函数的行为

任何人都可以解释我这段代码:

>>> round(0.45, 1)
0.5
>>> round(1.45, 1)
1.4
>>> round(2.45, 1)
2.5
>>> round(3.45, 1)
3.5
>>> round(4.45, 1)
4.5
>>> round(5.45, 1)
5.5
>>> round(6.45, 1)
6.5
>>> round(7.45, 1)
7.5
>>> round(8.45, 1)
8.4
>>> round(9.45, 1)
9.4
Run Code Online (Sandbox Code Playgroud)

更新

我想这是因为浮动表示.我对吗?

python rounding python-3.x

6
推荐指数
1
解决办法
4514
查看次数

标签 统计

python ×1

python-3.x ×1

rounding ×1