我想出了如何计算文件夹中的目录,但不知道如何编辑我的代码以递归计数子目录.任何帮助,将不胜感激.
到目前为止这是我的代码.
def nestingLevel(path):
count = 0
for item in os.listdir(path):
if item[0] != '.':
n = os.path.join(path,item)
if os.path.isdir(n):
count += 1 + nestingLevel(n)
return count
Run Code Online (Sandbox Code Playgroud)