我有一个文件名列表,并希望将它们打印为目录树:
files = ["foo/bar/Bla", "foo/bar/Foo", "foo/foo/Bsdf", "xsd/sdafd/saasf"]
[...]
# output should look like this
output = ['foo' : ['bar' : ['Bla', 'Foo'], 'foo' : ['Bsdf']], 'xsd' : ['sdafd' : ['saasf']]]
我尝试了不同的方法,但我不能比这样的事情更进一步:
['foo/bar': ['Bla', 'Foo'], 'foo/foo/': ['Bsdf'], 'xsd/sdafd' : ['saasf']]
或类似的...