📜  Python| Numpy np.char.endswith() 方法

📅  最后修改于: 2022-05-13 01:55:04.792000             🧑  作者: Mango

Python| Numpy np.char.endswith() 方法

np.char.endswith()方法的帮助下,当值以np.char.endswith()方法中传递的特定字符结尾时,我们可以获得布尔数组。

示例 #1:
在这个例子中我们可以看到,通过使用np.char.endswith()方法,我们能够在与np.char.endswith()方法中的字符串值匹配时获得布尔数组。

# import numpy
import numpy as np
  
# using np.char.endswith() method
a = np.array(['geeks', 'for', 'geeks'])
gfg = np.char.endswith(a, 'ks')
  
print(gfg)

输出 :

示例 #2:

# import numpy
import numpy as np
  
# using np.char.endswith() method
a = np.array([['geeks', 'for', 'geeks'], ['jitender', 'author', 'gfg']])
gfg = np.char.endswith(a, 'r')
  
print(gfg)

输出 :