📜  Numpy字符串操作 |开始()函数

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

Numpy字符串操作 |开始()函数

numpy.core.defchararray.startswith()函数返回一个布尔数组,该数组为 True,其中字符串元素以前缀开头,否则为 False。

代码#1:

Python3
# Python program explaining 
# numpy.char.startswith() function 
  
# importing numpy as geek  
import numpy as geek 
  
arr = "GeeksforGeeks - A computer science portal"
prefix = 'Geeks'
  
gfg = geek.char.startswith(arr, prefix, start = 0, end = None)
    
print (gfg)


Python3
# Python program explaining 
# numpy.char.startswith() function 
  
# importing numpy as geek  
import numpy as geek 
  
arr = "GeeksforGeeks - A computer science portal"
prefix = 'None'
  
gfg = geek.char.startswith(arr, prefix, start = 0, end = None)
    
print (gfg)


输出 :

代码#2:

Python3

# Python program explaining 
# numpy.char.startswith() function 
  
# importing numpy as geek  
import numpy as geek 
  
arr = "GeeksforGeeks - A computer science portal"
prefix = 'None'
  
gfg = geek.char.startswith(arr, prefix, start = 0, end = None)
    
print (gfg)

输出 :