Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python3 list files from particular directory [duplicate]

Tags:

How to list file names which are only from a particular directory? I don't want file names from sub-directory or anything.

like image 469
user3597719 Avatar asked May 27 '16 17:05

user3597719


People also ask

How do I get a list of files in a directory in Python?

Use os.listdir() function The os. listdir('path') function returns a list containing the names of the files and directories present in the directory given by the path .

How do I get a list of files in a directory and subfolders in Python?

os. listdir(path='. ') It returns a list of all the files and sub directories in the given path.


1 Answers

os.listdir(dir) 

Also see List files in ONLY the current directory

like image 176
sorin Avatar answered Oct 20 '22 00:10

sorin