Another way
astring = 'FTP://21.105.28.15/abc/test1.txt' astring2 = 'FTP://21.105.28.15/abc/def/test1.txt' def remover(astring): astring = astring.split('/') for index, item in enumerate(astring): if item == '': astring.remove(item) elif index in (0, 1): astring.remove(item) return '/'.join(astring) print(remover(astring)) print(remover(astring2))output
Output:/abc/test1.txt
/abc/def/test1.txt
little adjustment can remove the file at the end as well
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags