Python partition () method
description
partition () method is used according to the specified delimiter string segmentation.
If the string contains the specified delimiter returns a 3-element tuple, the first for the left delimiter substring, the second is the delimiter character, and the third for the right of the separator string.
partition () method is new in version 2.5.
grammar
partition () method syntax:
str.partition(str)
parameter
str: specify delimiter.
return value
Returns a 3-element tuple, the first for the left delimiter substring, the second is the delimiter character, and the third for the right of the separator string.
Examples
The following example shows that use partition () method:
#!/usr/bin/python str = "http://www.w3cschool.cc/" print str.partition("://")
The output is:
('http', '://', 'www.w3cschool.cc/')