#coding=utf-8
'''
Created on 2015-06-17
@author: xhw
'''
import os
class CountFile:
"""统计文件个数"""
def __init__(self):
self.root = "D:\ERRORHTML"
self.Num = 0
def countfile(self,path):
if not os.path.isdir(path):
return
fileList = os.listdir(path)
for fileName in fileList:
fileName = os.path.join(path,fileName)
if os.path.isdir(fileName):
self.countfile(fileName)
else:
self.Num+=1
def run(self):
self.countfile(self.root)
print self.Num
if __name__ == "__main__":
A = CountFile()
A.run()
递归统计文件个数--python
最新推荐文章于 2023-04-07 22:51:26 发布