numpy.strings.partition#
- strings.partition(a, sep)[原始碼]#
Partition each element in
aaroundsep.For each element in
a, split the element at the first occurrence ofsep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, the first item of the tuple will contain the whole string, and the second and third ones will be the empty string.- 參數:
- aarray-like, with
StringDType,bytes_, orstr_dtype Input array
- separray-like, with
StringDType,bytes_, orstr_dtype Separator to split each string element in
a.
- aarray-like, with
- 回傳值:
- out3-tuple:
array with
StringDType,bytes_orstr_dtype with the part before the separatorarray with
StringDType,bytes_orstr_dtype with the separatorarray with
StringDType,bytes_orstr_dtype with the part after the separator
也參考
範例
>>> import numpy as np >>> x = np.array(["Numpy is nice!"]) >>> np.strings.partition(x, " ") (array(['Numpy'], dtype='<U5'), array([' '], dtype='<U1'), array(['is nice!'], dtype='<U8'))