Advertisement
DeaD_EyE

os.walk

Apr 22nd, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. import os
  2.  
  3. #ret = []
  4. #for (root, dirs, files) in os.walk('.'):
  5. #    for dir in dirs:
  6. #        if '.' in dir:
  7. #            ret.append(os.path.join(root, dir))
  8.  
  9.  
  10. def find_files(topdir):
  11.     for (root, dirs, files) in os.walk(topdir):
  12.         for file in files:
  13.             path = os.path.join(root, file)
  14.             if os.path.isfile(path):
  15.                 yield path
  16.  
  17. for file in find_files('.'):
  18.     print(file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement