numpy.strings.endswith#
- strings.endswith(a, suffix, start=0, end=None)[源代码]#
返回一个布尔数组,如果
a中的字符串元素以suffix结尾,则为 True ,否则为 False .- 参数:
- a : 类数组,具有
StringDType,bytes_或str_dtype类数组,具有 - suffix:类数组,具有
StringDType,bytes_或str_数据类型类数组,具有 - start, endarray_like,具有任何整数 dtype
使用
start,从该位置开始测试.使用end,在该位置停止比较.
- a : 类数组,具有
- 返回:
- outndarray
布尔值的输出数组
参见
示例
>>> 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])