#!/usr/bin/env python
# 2.py
# use UTF-8
# Python 3.3.0
# os.walk()的使用
importos
# 枚举dirPath目录下的所有文件
defmain():
#begin
fileDir ="F:"+ os.sep +"aaa"# 查找F:\aaa 目录下
for root, dirs, files in os.walk(fileDir):
#begin
print(root)
print(dirs)
print(files)
#end
os.system("pause")
#end
if__name__ =='__main__':
#begin
main()
#end
# 输出
# F:\aaa
# ['4']
# ['1.txt', '2.txt', '3.txt']
# F:\aaa\4
# []
# ['5.txt', '6.txt', '7.txt']