frannyfran12312
frannyfran12312

Reputation: 3

How to print filenames in directory?

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

Answers (1)

elthwi
elthwi

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

Related Questions