好吧,我不仅在问题本身遇到问题,而且即使试图解释我的问题。我有一个目录树由大约7次迭代,所以:rootdir/a/b/c/d/e/f/destinationdir
Python Glob.glob:根和目标之间的目录数量的通配符
的事情是有的可有5倍子目录的水平,有些可能有多达十个,如:
rootdir/a/b/c/d/destinationdir
或:
rootdir/a/b/c/d/e/f/g/h/destinationdir
它们唯一共同的地方是目标目录总是被命名为相同的东西。我使用的水珠功能的方法如下:
for path in glob.glob('/rootdir/*/*/*/*/*/*/destinationdir'):
--- os.system('cd {0}; do whatever'.format(path))
然而,这仅适用于具备中级子目录是精确数量的目录。有什么办法可以让我不必指定那个数字subdirectories(asterices)
;换句话说,无论中间子目录的数量是多少,函数都会到达destinationdir,并允许我遍历它们。非常感谢!