os.walk function
import os
rootDir = 'test_dir'
numberOfDirs = 0
for root, dirs, files in os.walk(rootDir):
numberOfDirs += len(dirs)
print(numberOfDirs)
import os
rootDir = 'test_dir'
numberOfDirs = 0
for root, dirs, files in os.walk(rootDir):
numberOfDirs += len(dirs)
print(numberOfDirs)
Leave a Comment
Cancel reply