Операции с числовыми строками | функция splitlines ()

Опубликовано: 15 Марта, 2022

В этой функции numpy.core.defchararray.splitlines () каждый элемент в arr возвращает список строк в элементе с разрывом на границах строк.

Syntax : numpy.core.defchararray.splitlines(arr, keepends = None)

Parameters :

arr : [array-like of str]  Given array-like of string.

keepends : [bool, optional] Line breaks are not included in the resulting list unless keepends is given and true.

Return : [ndarray] Return the Array of list objects.

Code #1 :  

Python3

# Python program explaining 
# numpy.char.splitlines() function 
  
# importing numpy as geek  
import numpy as geek 
  
gfg = geek.char.splitlines("GeeksforGeeks A computer science portal for geeks")
    
print (gfg)

Выход :

[‘GeeksforGeeks ‘, ‘ A computer science portal ‘, ‘ for geeks’]

Code #2 :  

Python3

# Python program explaining 
# numpy.char.splitlines() function 
  
# importing numpy as geek  
import numpy as geek 
  
gfg = geek.char.splitlines("This is a Python-Numpy article for geeks")
    
print (gfg)

Выход :

[‘This is ‘, ‘ a Python-Numpy ‘, ‘ article ‘, ‘ for geeks’]

РЕКОМЕНДУЕМЫЕ СТАТЬИ