なぜこの再帰関数は、なぜ、それが新しい発見を既存の辞書に追加しないのかを循環するたびに1つ以上の辞書を返すことです。python関数がより多くのdictを返す
ないと私はos.walkを使用したくないとはい私は認識してtheresのノーリターン
def retFiles(dir):
data = {}
root = set()
os.chdir(dir)
cwd = os.getcwd()
for i in os.listdir(cwd):
if os.path.isfile(i):
data.setdefault(i, set())
root.add(os.path.relpath(dir).replace("\\", "/"))
data[i] = root
else:
retFiles(i)
print(data)
うわー、このコードは混乱しています。正確に何を達成したいですか? –
[python recursive directory reading]の複製が可能です(http://stackoverflow.com/questions/8552131/python-recursive-directory-reading) –