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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -