Convert File Path List To Tree
There is a python file path list like below: file_path_list = ['test/dir1/log.txt', 'test/dir1/dir2/server.txt', 'test/manage/img.txt'] I want to convert it to a tree. the expect
Solution 1:
One way is to split the strings at '/' and put them in a defaultdict of defaultdicts, see defaultdict of defaultdict, nested.
Post a Comment for "Convert File Path List To Tree"