Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python file name from absolute 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
Source by docs.python.org #
 
PREVIOUS NEXT
Tagged: #python #file #absolute #path
ADD COMMENT
Topic
Name
8+1 =