+ 2
What is partition function for string in python?
2 Respuestas
+ 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')
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.