numpy.char.endswith#
- char.endswith(a, suffix, start=0, end=None)[原始碼]#
傳回布林陣列,若
a
中的字串元素以suffix
結尾則為 True,否則為 False。- 參數:
- aarray-like,具有
StringDType
、bytes_
或str_
dtype - suffixarray-like,具有
StringDType
、bytes_
或str_
dtype - start, endarray_like,具有任何整數 dtype
使用
start
,從該位置開始測試。使用end
,在該位置停止比較。
- aarray-like,具有
- 傳回:
- 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])