1import os
2
3path ="C:/workspace/python"
4#we shall store all the file names in this list
5filelist = []
6
7for root, dirs, files in os.walk(path):
8 for file in files:
9 #append the file name to the list
10 filelist.append(os.path.join(root,file))
11
12#print all the file names
13for name in filelist:
14 print(name)
1for path, subdirs, files in os.walk(root):
2 for name in files:
3 print os.path.join(path, name)
4