【发布时间】:2014-10-03 06:34:29
【问题描述】:
有没有简单的方法来生成这样的 JSON?我找到了os.walk() 和os.listdir(),所以我可以递归下降到目录并构建一个python 对象,嗯,但这听起来像是在重新发明一个轮子,也许有人知道这样的任务的工作代码?
{
"type": "directory",
"name": "hello",
"children": [
{
"type": "directory",
"name": "world",
"children": [
{
"type": "file",
"name": "one.txt"
},
{
"type": "file",
"name": "two.txt"
}
]
},
{
"type": "file",
"name": "README"
}
]
}
【问题讨论】:
标签: python json python-2.7 data-structures tree