Home > Article > Backend Development > Share a detailed explanation of the string function (partition) in Python
partition(...) S.partition(sep) -> (head, sep, tail) Search for the separator sep in S, and return the part before it, the separator itself, and the part after it. If the separator is not found, return S and two empty strings.
For example:
>>> a = 'changzhi1990' >>> a.rpartition('h') ('changz', 'h', 'i1990')
You can see that a three-element tuple is returned, which is the string on the left side of 'h'. #, the separator 'h' itself, and the string to the right of the separator 'h'. Note: r means matching from right to left.
>>> a = 'changzhi1990' >>> a.partition('h') ('c', 'h', 'angzhi1990')Here is matching from left to right. 【Related recommendations】
Example tutorial of partition string function in Python
2.Share a string Example code of function (partition)
3.MySQL-data table partition technology PARTITION code example analysis
The above is the detailed content of Share a detailed explanation of the string function (partition) in Python. For more information, please follow other related articles on the PHP Chinese website!