‘‘‘
使用递归来遍历目录
‘‘‘
def getall(path):
listall = os.listdir(path)
print(listall)
for item in listall:
abspath = os.path.join(path,item)
if os.path.isdir(abspath):
print("目录:%s"%abspath)
getall(abspath)
else:
print("文件",abspath)
getall(r"D:\Oracle考试")
原文:http://blog.51cto.com/victor2016/2060872