为了使我的问题清楚,如果我有一个数组a为Out [123]:[1,3,4,6,9,10,54]当我尝试搜索列表中的数字时,searchsort返回正确的值,但是当我尝试不在列表中的东西,它返回一个荒谬的值
这是一些结果
In [131]: a
Out[131]: [1, 3, 4, 6, 9, 10, 54]
In [132]: searchsorted(a,1)
Out[132]: 0
In [133]: searchsorted(a,6)
Out[133]: 3
In [134]: searchsorted(a,[9,54,1])
Out[134]: array([4, 6, 0])
In [135]: searchsorted(a,[9,54,1,0])
Out[135]: array([4, 6, 0, 0])
***> # here 0 is not in the list, but turns up @ position 0***
In [136]: searchsorted(a,740)
Out[136]: 7
***> # here 0 is not in the list, but turns up @ position 7***
Run Code Online (Sandbox Code Playgroud)
为什么会这样?