numpy.char.endswith#

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

返回一个布尔数组,如果 a 中的字符串元素以 suffix 结尾,则为 True ,否则为 False .

参数:
a: 类数组,具有 StringDType , bytes_str_ dtype类数组,具有
suffix : 类数组,具有 StringDType , bytes_ , 或 str_ dtype类数组,具有
start, end类数组对象,具有任何整数dtype

使用 start ,从该位置开始测试. 使用 end ,在该位置停止比较.

返回:
outndarray

布尔值的输出数组

参见

str.endswith

示例

>>> import numpy as np
>>> s = np.array(['foo', 'bar'])
>>> s
array(['foo', 'bar'], dtype='<U3')
>>> np.strings.endswith(s, 'ar')
array([False,  True])
>>> np.strings.endswith(s, 'a', start=1, end=2)
array([False,  True])