python学习笔记_文件遍历
#!usr/bin/env python# -*- coding: UTF-8 -*-import osimport stringdef vistDir2(path):list_dirs = os.walk(path)result=[]for root ,dirs,files in list_dirs:print rootp
·
#!usr/bin/env python
# -*- coding: UTF-8 -*-
import os
import string
def vistDir2(path):
list_dirs = os.walk(path)
result=[]
for root ,dirs,files in list_dirs:
print root
print dirs
print files
'''
for d in dirs: #得到所有的目录
print os.path.join(root,d)
'''
for file in files: #得到所有的文件
temp = os.path.join(root,file)
更多推荐
已为社区贡献1条内容
所有评论(0)