Willie Koomson
Willie Koomson

Reputation: 529

Python: Inputting files in a directory to a list

I understand that with the glob or listdir modules you can get a list of all the files in a directory. However, I need to know how assign the output from glob or listdir to a variable, in list form, like listdir("/some/file/") = list and then be able to print list and see a list of all files in /some/file/. Please help me out here.

Upvotes: 0

Views: 147

Answers (1)

Sven Marnach
Sven Marnach

Reputation: 601451

Are you looking for

filelist = os.listdir("/some/path/")
print filelist

If so, consider to work through a Python tutorial :)

Upvotes: 2

Related Questions