码迷,mamicode.com
首页 > 编程语言 > 详细

python os.walk

时间:2016-07-14 17:24:11      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:

#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‘]
>>> 

 

python os.walk

标签:

原文地址:http://www.cnblogs.com/yuuwee/p/5671046.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!