The .basename()
method returns the part of a pathname after the last forward-slash.
Syntax
os.path.basename(path_string)
The path_string
must be a string or byte data type.
Codebyte Example
The following example showcases the .basename()
method using a Codecademy course URL:
Code Output