numpy.char.endswith#
- char.endswith(a, suffix, start=0, end=None)[source]#
返回一个布尔数组,当
a
中的字符串元素以suffix
结尾时为 True,否则为 False。- 参数:
- a类数组,其 dtype 为
StringDType
、bytes_
或str_
- suffix类数组,其 dtype 为
StringDType
、bytes_
或str_
- start, end类数组,其 dtype 为任意整数类型
使用
start
时,从该位置开始测试。使用end
时,在该位置停止比较。
- a类数组,其 dtype 为
- 返回:
- 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])