Back
How can I list all files of a directory in Python and add them to a list?
For listing all Python files in directory you can use the glob module, as it does pattern matching and expansion.
import glob print(glob.glob("/home/adam/*.txt"))
import glob
print(glob.glob("/home/adam/*.txt"))
To know more about this you can have a look at the following video tutorial:-
31k questions
32.8k answers
501 comments
693 users