How to remove the last part of a URL after the last slash (/) in Python

1 Answer

0 votes
url = "http://www.website.com/abc/xyz"
   
url = url.rsplit('/',1)[0]
 
print(url)  
 
  
  
'''
run:

http://www.website.com/abc
  
'''

 



answered Feb 19, 2020 by avibootz

Related questions

3 answers 359 views
1 answer 264 views
1 answer 213 views
2 answers 286 views
1 answer 202 views
1 answer 173 views
...