I'm try to split text from string, but I can't.
I have 1;2 | 2;4
, for example in my string, and I want to:
['1;2', '|', '2;4']
I'm try to split text from string, but I can't.
I have 1;2 | 2;4
, for example in my string, and I want to:
['1;2', '|', '2;4']
You can use str.partition
:
>>> '1;2 | 2;4'.partition("|")
('1;2 ', '|', ' 2;4')