Uncategorized

arrays – Is it possible to map our computer directories to a dictionary in Python


I’ve been trying to create a function that is able to pic up the folder configuration of my computer and transform that in a dictionary. As an example lets image that I have 3 folder and 2 files inside the rood of my computer, and within the first folder there are one more folder, something like this:

root|
    |
    |- folder1-| 
    |----------|-folder11
    |- folder2
    |- folder3
    |- file1
    |- file2

I need that the program convert that indo:

{root: {folder1: {folder11}, folder2:{}, folder3:{}}}

Of course I wanted this function to work for any folder configuration.
And maybe, it would be cool to be able to convert this dictionary into an array.

If anyone could help me I would be grateful

I try several things but I always got lost when it came to making the function capable of searching within folders that were within folders, I never managed to generalize the system



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *