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
要搜尋的範圍,以切片表示法解釋。
- aarray_like, 具有
- 回傳值:
- yndarray
整數的輸出陣列
參見
範例
>>> import numpy as np >>> a = np.array(["NumPy is a Python library"]) >>> np.strings.find(a, "Python") array([11])