Python中的圆形浮点数

m.c*_*.96 1 python floating-point precision floating-accuracy python-3.x

我在 Python 中遇到了浮动问题...

我在一个变量中有这个:

i = 9.600000000000001
Run Code Online (Sandbox Code Playgroud)

我会这样改造:

i = 9.60000
Run Code Online (Sandbox Code Playgroud)

小数点后有五个数字并四舍五入。

Wes*_*ley 7

>>> format(9.60000001,'.5f')                                                                                                            
'9.60000'
>>> 
Run Code Online (Sandbox Code Playgroud)