numpy.strings.rpartition#
- strings.rpartition(a, sep)[源]#
围绕最右侧分隔符对每个元素进行分区(拆分)。
对于
a
中的每个元素,在sep
的最后一次出现处拆分该元素,并返回一个包含分隔符前部分、分隔符本身和分隔符后部分的 3 元组。如果未找到分隔符,则元组的第三项将包含整个字符串,而第一项和第二项将是空字符串。- 参数:
- a类数组,其 dtype 为
StringDType
、bytes_
或str_
输入数组
- sep类数组,其 dtype 为
StringDType
、bytes_
或str_
用于拆分
a
中每个字符串元素的分隔符。
- a类数组,其 dtype 为
- 返回:
- out3 元组:
dtype 为
StringDType
、bytes_
或str_
的数组,包含分隔符前部分dtype 为
StringDType
、bytes_
或str_
的数组,包含分隔符本身dtype 为
StringDType
、bytes_
或str_
的数组,包含分隔符后部分
另请参阅
示例
>>> import numpy as np >>> a = np.array(['aAaAaA', ' aA ', 'abBABba']) >>> np.strings.rpartition(a, 'A') (array(['aAaAa', ' a', 'abB'], dtype='<U5'), array(['A', 'A', 'A'], dtype='<U1'), array(['', ' ', 'Bba'], dtype='<U3'))