код до сих пор:python - Как преобразовать отношения родитель-ребенок в словарь?
for root, dirs, files in os.walk(path):
for directory in dirs:
if directory.endswith("GUI"): # Get only folders that end with GUI
print "Parent is: ", (os.path.join(root, directory))
os.chdir(os.path.join(root, directory))
for file in glob.glob("*.b"): # Get only files that end with b
print "Child is: ", (file)
dictionaryParentChild[directory] = file
return dictionaryParentChild
Ток: Этот код возврата только 1 родитель: 1 ребенок Желаемая: Код должен возвращать 1 родитель: многие дети
спасибо ребята за ваши ответы. он работает сейчас. – george