<p>我想找到特定文件夹的路径,只有特定的文件夹兄弟</p>
<p>例如:
我想找到所有名为:<code>zeFolder</code>的文件夹,其中有同级文件夹<code>brotherOne</code>和{<cd3>}</p>
<p>|-dad1<br/>|---BrotherRone<br/>|---brotherFour<br/>|---zeFolder(<strong><em>不匹配</em></strong>)</p>
<p>|-dad2<br/>|---BrotherRone<br/>|---brotherTwo<br/>|---zeFolder(♥♥♥匹配♥♥♥) 在</p>
<p>[…]</p>
<p>下面是我的代码,但是通过这个解决方案,我可以找到所有的文件夹。在</p>
<pre><code>import os
for root, dirs, files in os.walk("/"):
#print (dirs)
for name in dirs:
if name == 'totolo':
print ('finded')
print(os.path.join(root, name))
</code></pre>
<p>我不知道如何使用条件语句来做到这一点</p>
<p>谢谢你的帮助。在</p>
<pre><code>import os
import glob
filelist = glob.glob(r"dad1/*brotherOne")
for f in filelist:
print(f)
filelist = glob.glob(r"dad1/*brotherTwo")
for f in filelist:
print(f)
</code></pre>
<p>你也可以试试球技术。在for循环中做你想做的任何事。在</p>