numpy.strings.find#

strings.find(a, sub, start=0, end=None)[source]#

針對每個元素,傳回字串中找到子字串 sub 的最低索引值,使得 sub 包含在 [start, end] 範圍內。

參數:
aarray_like, 具有 StringDType, bytes_str_ dtype
subarray_like, 具有 np.bytes_np.str_ dtype

要搜尋的子字串。

start, endarray_like, 具有任何整數 dtype

要搜尋的範圍,以切片表示法解釋。

回傳值:
yndarray

整數的輸出陣列

參見

str.find

範例

>>> import numpy as np
>>> a = np.array(["NumPy is a Python library"])
>>> np.strings.find(a, "Python")
array([11])