【发布时间】:2018-05-24 17:19:39
【问题描述】:
我可以知道为什么 ndarray 允许浮点索引访问,这是什么意思?
>>> wk1 = numpy.arange(10)
>>> wk1[1:2.8]
array([1])
>>> wk1 = [1,2,3,4,5,6,7,8,9,10]
>>> wk1[1:2.8]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: slice indices must be integers or None or have an __index__ method
>>>
【问题讨论】:
-
这不再起作用了。见stackoverflow.com/a/43305317/2898712