python list() listdir code example
Example 1: list directory in python
from os import listdir
## Prints the current directory as a list (including file types)
print(os.listdir())
Example 2: python os.listdir
#!/usr/bin/python
import os, sys
# Open a file
path = "/var/www/html/"
dirs = os.listdir( path )
# This would print all the files and directories
for file in dirs:
print file