Answers for "python get filename from path"

31

python get filename from path

import os
print(os.path.basename(your_path))
Posted by: Guest on February-28-2020
11

get files in directory python

import os
files_and_directories = os.listdir("path/to/directory")
Posted by: Guest on June-12-2020
1

python extract thefile name from relative path

import os
infile = "./../../../../_data/matrix_data/5mer_normalized.tsv"
print(os.path.basename(infile))
>>> "5mer_normalized.tsv"
Posted by: Guest on October-17-2020
0

Extract filename from path in Python

filename = os.path.basename("path/to/file/sample.txt")
Posted by: Guest on August-31-2021

Code answers related to "python get filename from path"

Python Answers by Framework

Browse Popular Code Answers by Language