How to get a list of filenames(without extension) in directory in python? -
assume folder structure
+data -abc.jpg -db.jpg -ap.jpg
input 'path/to/data'
expected output ['abc','db','ap']
i saw many similar questions did not wanted. prefer use os module in python.
import os files_no_ext = [".".join(f.split(".")[:-1]) f in os.listdir() if os.path.isfile(f)] print(files_no_ext)
Comments
Post a Comment