numpy.char.splitlines#
- char.splitlines(a, keepends=None)[源代码]#
对于 a 中的每个元素,返回元素中各行的列表,在行边界处断开.
逐元素调用
str.splitlines.- 参数:
- a : 类数组,具有
StringDType,bytes_或str_dtype类数组,具有 - keependsbool, 可选
除非给出 keepends 并且为 true,否则行分隔符不包含在结果列表中.
- a : 类数组,具有
- 返回:
- outndarray
列表对象数组
示例
>>> np.char.splitlines("first line\nsecond line") array(list(['first line', 'second line']), dtype=object) >>> a = np.array(["first\nsecond", "third\nfourth"]) >>> np.char.splitlines(a) array([list(['first', 'second']), list(['third', 'fourth'])], dtype=object)