numpy.char.split#

char.split(a, sep=None, maxsplit=None)[源代码]#

对于 a 中的每个元素,返回字符串中的单词列表,使用 sep 作为分隔符字符串.

按元素调用 str.split .

参数:
a: 类数组,具有 StringDType , bytes_str_ dtype类数组,具有
sepstr 或 unicode,可选

如果未指定 sep 或为 None,则任何空白字符串都将作为分隔符.

maxsplitint, optional

如果给出了 maxsplit ,则最多完成 maxsplit 次拆分.

返回:
outndarray

列表对象数组

参见

str.split , rsplit

示例

>>> import numpy as np
>>> x = np.array("Numpy is nice!")
>>> np.strings.split(x, " ")  
array(list(['Numpy', 'is', 'nice!']), dtype=object)  
>>> np.strings.split(x, " ", 1)  
array(list(['Numpy', 'is nice!']), dtype=object)