numpy.char.index#

char.index(a, sub, start=0, end=None)[源代码]#

find 类似,但当未找到子字符串时会引发 ValueError .

参数:
a : 类数组,具有 StringDType , bytes_str_ dtype类数组,具有
sub : 类数组, with StringDType , bytes_ , or str_ dtype类数组,具有
start, end类数组,具有任何整数数据类型,可选
返回:
outndarray

整数的输出数组.

参见

find , str.index

示例

>>> import numpy as np
>>> a = np.array(["Computer Science"])
>>> np.strings.index(a, "Science", start=0, end=None)
array([9])