在下面的例子中
比较失败是因为空格的原因。是否有一个Numpy内置函数可以做相当于的事情?
哪个能给出正确的结果?
In [8]: import numpy as np
In [9]: strings = np.array(['hello ', 'world '], dtype='|S10')
In [10]: strings == 'hello'
Out[10]: array([False, False], dtype=bool)
比较失败是因为空格的原因。是否有一个Numpy内置函数可以做相当于的事情?
In [12]: np.array([x.strip()=='hello' for x in strings])
Out[12]: array([ True, False], dtype=bool)
哪个能给出正确的结果?