Reputation: 3
How can I print all filenames in a directory using python? Why isn't this working?
for file in glob.glob("*"):
print(file)
Upvotes: 0
Views: 36
Reputation: 749
That should work. I think you're just missing the import. Try:
import glob
for file in glob.glob("*"):
print(file)
Upvotes: 1