Monday, April 18, 2011

How to list files in a directory

This code will print the content of the directory "/home/giu/Documents/secrets"
import os

fileList = os.listdir("/home/giu/Documents/secrets")
for fileName in fileList:
 print fileName
howtoconquertheworld.pdf
hellokitty.jpg
loveletter.txt
misterious_pictures

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.