0

I have

path='/path/2/foo'

ls $path

yields a list of files in the path. What do I do if I want to convert that to a list of strings of filenames?

Thanks

user3659451
  • 1,913
  • 9
  • 30
  • 43

1 Answers1

1

Use os.listdir:

import os
path = '/path/2/foo'
filenames = os.listdir(path)
falsetru
  • 357,413
  • 63
  • 732
  • 636