Python zdobądź nazwę pliku ze ścieżki
import os
print(os.path.basename(your_path))
Itchy Ibis
import os
print(os.path.basename(your_path))
# Basic syntax:
import os
os.path.basename('/path/to/filename.txt')
# Example usage:
os.path.basename('/path/to/filename.txt')
--> filename.txt
# Note, to get the path instead of the filename, use:
os.path.dirname('/path/to/filename.txt')
--> /path/to
// Let's an <a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/Location.pathname"> element be in the document
var anchor = document.getElementById("myAnchor");
var result = anchor.pathname; // Returns:'/en-US/docs/Location.pathname'