我想存储一个JSON结构,其中包含我目前正在处理的项目和文件。文件结构如下所示:
|-project1
|--sequence1
|----file1.ext
|----file2.ext
|-project2
|--sequence1
|----file1.ext
|----file2.ext
|-project3
|--sequence3
|----file1.ext
|----file2.ext
JSON版本将如下所示:
data = [
{
type: "folder",
name: "project1",
path: "/project1",
children: [
{
type: "folder",
name: "sequence1",
path: "/project1/sequence1",
children: [
{
type: "file",
name: "file1.ext",
path: "/project1/sequence1/file1.ext"
} , {
type: "file",
name: "file2.ext",
path: "/project1/sequence1/file2.ext"
...etc
}
]
}
]
}
]
是否可以使用Python将此结构呈现为实际的目录和文件?(它可以是空文件)。另一方面,我想构建一个遍历现有目录的函数,返回类似的JSON代码。
https://stackoverflow.com/questions/26288551
复制相似问题