numpy.strings.index#
- strings.index(a, sub, start=0, end=None)[source]#
類似
find
,但當找不到子字串時會引發ValueError
。- 參數:
- a類陣列,具有
StringDType
、bytes_
或str_
dtype - sub類陣列,具有
StringDType
、bytes_
或str_
dtype - start, end類陣列,具有任何整數 dtype,可選
- a類陣列,具有
- 回傳:
- outndarray
整數的輸出陣列。
範例
>>> import numpy as np >>> a = np.array(["Computer Science"]) >>> np.strings.index(a, "Science", start=0, end=None) array([9])