NumPy 的 endswith(~)
方法檢查輸入數組中的每個字符串是否以指定的子字符串結尾。
參數
1. a
| array-like
輸入字符串數組。
2. suffix
| array-like
您要檢查的結束子字符串。
3. start
| int
| optional
開始檢查的起始索引(包含)。
4. end
| int
| optional
要結束檢查的索引(含)。
返回值
如果 a
是標量,則返回單個布爾值。否則,返回 NumPy 布爾值數組。
例子
指定後綴
np.char.endswith(["abcde"], ["de"])
array([ True])
指定開始
np.char.endswith(["abcde"], ["de"], start=1)
array([True])
在這裏,我們從索引 1 開始,這意味著我們正在檢查字符串 "bcde"
。
指定結束
np.char.endswith(["abcde"], ["cde"], end=2)
array([False])
在這裏,我們以索引 2 結束,這意味著我們正在檢查字符串 "ab"
,該字符串顯然不以 "cde"
結尾。
相關用法
- Python enchant.request_dict()用法及代碼示例
- Python enum.IntEnum用法及代碼示例
- Python enchant.get_enchant_version()用法及代碼示例
- Python enchant.request_pwl_dict()用法及代碼示例
- Python enumerate方法用法及代碼示例
- Python enchant.Dict()用法及代碼示例
- Python enum.auto()用法及代碼示例
- Python enchant.list_languages()用法及代碼示例
- Python enumerate用法及代碼示例
- Python enumerate()用法及代碼示例
- Python enchant.DictWithPWL()用法及代碼示例
- Python enchant.dict_exists()用法及代碼示例
- Python email.message.Message.walk用法及代碼示例
- Python numpy matrix eye()用法及代碼示例
- Python email.headerregistry.DateHeader用法及代碼示例
- Python NumPy expandtabs方法用法及代碼示例
- Python math expm1()用法及代碼示例
- Python email.message.EmailMessage.add_header用法及代碼示例
- Python emoji轉text用法及代碼示例
- Python NumPy expand_dims方法用法及代碼示例
- Python eval用法及代碼示例
- Python email.utils.getaddresses用法及代碼示例
- Python email.header.decode_header用法及代碼示例
- Python email.message.EmailMessage.walk用法及代碼示例
- Python exponential轉float用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | endswith method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。