1

I need to make a Dictionary out of some folder hierachy.

I have a folder in /home/Desktop/songs --- inside there are Folder: "A" and another "B". Inside of folder A and B there are folder: "1" and "2"

I want to get the FOLDERS inside "songs" and get the folders inside A and B . Then make a Dictionary with them. Like THIS:

A={'1','2'}
B={'1','2'}

That way, If I update my folders the script gets updated.

I started looking to something like this:

os.chdir('/home/Desktop/songs')
letter = [d for d in os.listdir('.') if os.path.isdir(d)]
print letter
-----> A,B

But I dont know how to append them in a dictionary.

4

1 に答える 1