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