python os.walk

#coding utf-8
import os

def main():
    fileDir = 'F:'+os.sep+'aaa'
    for root,dirs,files in os.walk(fileDir):
        print (root)
        print (dirs)
        print (files)
    os.system('pause')
    
if __name__=='__main__':
    main()
>>> ================================ RESTART ================================
>>> 
F:\aaa
['4']
['1.txt', '2.txt', '3.txt']
F:\aaa\4
['8']
['5.txt', '6.txt', '7.txt']
F:\aaa\4\8
[]
['10.txt', '11.txt', '9.txt']
>>> 

 

posted @ 2016-07-14 17:10  yuuwee  阅读(151)  评论(0编辑  收藏  举报