First page Back Continue Last page Overview Graphics

Partition

str.partition(sep)

Split the string at the first occurrence of sep, 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, return a 3-tuple containing the string itself, followed by two empty strings.

>>> s = "34;45;98;3"

>>> s.partition(";")

('34', ';', '45;98;3')

>>>

>>> # compare with

...

>>> s.split(";",1)

['34', '45;98;3']