Tuesday, March 22, 2016

list directory contents from python script or console

http://stackoverflow.com/questions/11968976/list-files-in-only-the-current-directory

>>> print os.listdir(os.curdir)
['test.txt', 'output.mid', 'midi_1.py', '_midi_1.py', 'song.txt', 'output_test.mid']


>>> print os.listdir('.')
['test.txt', 'output.mid', 'midi_1.py', '_midi_1.py', 'song.txt', 'output_test.mid']

>>> print os.listdir('./')
['test.txt', 'output.mid', 'midi_1.py', '_midi_1.py', 'song.txt', 'output_test.mid']

No comments:

Post a Comment