Skip to content
  • Tutorials
    • c programming
      • libraries
    • c++
    • Linux
    • Python
    • batch programming
    • Technology
  • IDE
  • Tools
split string form url last slash 1

split string form url last slash

June 11, 2022 by Anurag batra
url = 'http://www.test.com/TEST1'
l = url.split('/', -1)[-1]

Here is what the above code is Doing:
1. It’s splitting the URL into a list of strings, using ‘/’ as the separator.
2. It’s taking the last element of the list, which is the last part of the URL.

Categories Python Examples
Post navigation
read database pandas
how to access variable of one function in another function in python
© MyEduKit - 2022 . All Rights Reserved.