Python中的一个错误:np.arange(-0.1,0.2,0.1)

时间:2015-02-19 09:08:43

标签: python-2.7 python-3.x

我在Python2 / 3中发现了一个奇怪的东西。这似乎是一个错误? I only put an example using Python2

我认为np.arange(-0.1,0.2,0.1)应该给出[-0.1,0.1,0.1]?任何解释? 感谢

1 个答案:

答案 0 :(得分:1)

http://docs.scipy.org/doc/numpy/reference/generated/numpy.arange.html

"当使用非整数步骤(例如0.1)时,结果通常不一致。最好在这些情况下使用linspace。"