首页 > 编程语言 > 详细

python os.walk

时间:2016-07-14 17:23:50      阅读:235      评论: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)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!