2024-04-26 23:50:10 发布
网友
我对numpy linspace有意见
import numpy as np temp = np.linspace(1,2,11) for t in temp: print(t)
此返回:
1.7的值看起来绝对是错误的。在
{a1}似乎与此有关
有人曾经有过这样的问题吗numpy.linspace? 这是一个已知的问题吗?在
弗朗索瓦
这与numpy无关,请考虑:
numpy
>>> temp = np.linspace(1,2,11) >>> temp array([1. , 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2. ]) >>> # ^ look, numpy displays it fine >>> for t in temp: ... print(t) ... 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7000000000000002 1.8 1.9 2.0
“问题”在于计算机一般如何表示浮点数。请参见:https://docs.python.org/3/tutorial/floatingpoint.html。在
这与
numpy
无关,请考虑:“问题”在于计算机一般如何表示浮点数。请参见:https://docs.python.org/3/tutorial/floatingpoint.html。在
相关问题 更多 >
编程相关推荐