How To Split A String In Python With A Remainder?
In python3 I have e.g. the following string 433 65040 9322 /opt/conda/envs/python2/bin/python -m ipykernel_launcher which I want to split in four parts: the first three eleme
Solution 1:
You can use split
with the maxsplit
parameter:
text = " 433 65040 9322 /opt/conda/envs/python2/bin/python -m ipykernel_launcher"
text.strip().split(maxsplit=3) # max 3 splits
# ['433', '65040', '9322', '/opt/conda/envs/python2/bin/python -m ipykernel_launcher']
Post a Comment for "How To Split A String In Python With A Remainder?"