import os
def countFile(dir):
tmp = 0
for item in os.listdir(dir):
if os.path.isfile(os.path.join(dir, item)):
tmp += 1
else:
tmp += countFile(os.path.join(dir, item))
return tmp
原文链接:https://blog.csdn.net/HOMEGREAT/java/article/details/82861373