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