0 votes
1 view
in Python by (47.8k points)

How can I list all files of a directory in Python and add them to a list?

1 Answer

0 votes
by (107k points)
edited by

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"))

To know more about this you can have a look at the following video tutorial:-

Related questions

+1 vote
1 answer
asked May 18, 2019 in Python by Nigam (4.1k points)
0 votes
1 answer
0 votes
1 answer
asked Sep 16, 2019 in Python by Sammy (47.8k points)
+1 vote
2 answers
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...