numpy.strings.endswith#
- strings.endswith(a, suffix, start=0, end=None)[source]#
返回一個布林陣列,當
a
中的字串元素以suffix
結尾時為 True,否則為 False。- 參數:
- a類陣列,具有
StringDType
、bytes_
或str_
資料類型 - suffix類陣列,具有
StringDType
、bytes_
或str_
資料類型 - start, end類陣列,具有任何整數資料類型
使用
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])