numpy.char.endswith#

char.endswith(a, suffix, start=0, end=None)[原始碼]#

傳回布林陣列,若 a 中的字串元素以 suffix 結尾則為 True,否則為 False

參數:
aarray-like,具有 StringDTypebytes_str_ dtype
suffixarray-like,具有 StringDTypebytes_str_ dtype
start, endarray_like,具有任何整數 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])