numpy.char.find#

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

对于每个元素,返回字符串中找到子字符串 sub 的最低索引,使得 sub 包含在范围 [ start , end ) 中.

参数:
a : 类数组,具有 StringDType , bytes_str_ 数据类型array_like, with StringDType, bytes_ or str_ dtype
sub : 类数组,具有 np.bytes_np.str_ 数据类型array_like, with np.bytes_ or 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])