+ 2

What is partition function for string in python?

28th Aug 2018, 11:43 AM
Maninder $ingh
Maninder $ingh - avatar
2 odpowiedzi
+ 4
It splits a string a puts the result in a tuple, try this: x = "16.11" print(x.partition('.')) The result is: ('16', '.', '11')
28th Aug 2018, 12:17 PM
Paul
Paul - avatar
0
Note that this will only partition on the first occurrence of the separator. x.split('.') will split on all occurrences but it will not include the separator.
1st Sep 2018, 7:21 PM
benjamin