Skip to content

Instantly share code, notes, and snippets.

@kennethzfeng
Created March 28, 2014 05:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennethzfeng/9826005 to your computer and use it in GitHub Desktop.
Save kennethzfeng/9826005 to your computer and use it in GitHub Desktop.
Demo on Python's os module's walk function
#!/usr/bin/python
import os
def walk(dir):
for (root, dirs, files) in os.walk(dir):
for file in files:
path = os.path.join(root, file)
print(repr(path))
if __name__ == "__main__":
cwd = os.getcwd()
walk(cwd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment