os.listdir by code example
Example 1: os.listdir in python
#import libs
import os
#set path of file or website on which listdir is to be applied
path='/users/desktop/dummy'
#Print all data in path
for file in os.listdir(path):
print(file)
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