import glob,os
def tree( base ):
if base[-1] == '/':
base = base[:-2]
for f in glob.glob(base+'/**', recursive=True):
if os.path.isdir(f):
print(f)
tree( '.' )
glob(pattern, recursive=True)のpattern が**の場合、下位ディレクトリにもマッチする。ただし、patternが'/'(unix系)で終わる場合は下位ディレクトリにマッチしない。