Skip to content

Instantly share code, notes, and snippets.

@soneedu
Forked from rswofxd/dirlist.py
Created June 24, 2014 08:47
Show Gist options
  • Save soneedu/f1c06b37bbf76057a2fd to your computer and use it in GitHub Desktop.
Save soneedu/f1c06b37bbf76057a2fd to your computer and use it in GitHub Desktop.
#coding:utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
from os.path import basename, isdir
from os import listdir
def traverse(path, depth=0):
print depth* '| ' + '|_', basename(path)
if(isdir(path)):
for item in listdir(path):
traverse(path+'/'+item, depth+1)
if __name__ == '__main__':
traverse('./')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment