numpy.strings.startswith#
- strings.startswith(a, prefix, start=0, end=None)[原始碼]#
返回一個布林陣列,若
a
中的字串元素以prefix
開頭,則為 True,否則為 False。- 參數:
- a類陣列,具有
StringDType
、bytes_
或str_
dtype - prefix類陣列,具有
StringDType
、bytes_
或str_
dtype - 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.startswith(s, 'fo') array([True, False]) >>> np.strings.startswith(s, 'o', start=1, end=2) array([True, False])