#!/usr/bin/env python
# coding:UTF-8
import os
filepath = '/root/python'
dir_files_list = sorted([os.path.join(filepath, dirfiles) for dirfiles in os.listdir(filepath)])
#print dir_files_list
def fun(rootdir):
for dirfiles in sorted(os.listdir(rootdir)):
path_dirfiles = os.path.join(rootdir, dirfiles)
if os.path.isdir(path_dirfiles):
print '\033[34;1m%s\033[0m' % path_dirfiles
fun(path_dirfiles) #递规调用fun()
else:
print '%s' % os.path.split(path_dirfiles)[1]
if __name__ == "__main__":
fun(filepath)
阅读(1512) | 评论(0) | 转发(0) |