Answers for "delimiter in python"

24

split string python

file='/home/folder/subfolder/my_file.txt'
file_name=file.split('/')[-1].split('.')[0]
Posted by: Guest on April-01-2020
0

only split from third delimiter python

# using rsplit() 
# Split on last occurrence of delimiter 
res = test_string.rsplit(', ', 1)
Posted by: Guest on November-24-2020

Python Answers by Framework

Browse Popular Code Answers by Language