Skip to content

Instantly share code, notes, and snippets.

@jackeyGao
Last active August 11, 2016 05:11
Show Gist options
  • Save jackeyGao/92370ada79868abe3d5f4ec1c19f8f6f to your computer and use it in GitHub Desktop.
Save jackeyGao/92370ada79868abe3d5f4ec1c19f8f6f to your computer and use it in GitHub Desktop.
Python 树状字典
{
"A": {
"AA": {
"AAA": "Hello"
}
},
"B": {
"BB": {
"BBB": "world"
}
}
}
import json
from collections import defaultdict
d = defaultdict(lambda: defaultdict(tree))
d["A"]["AA"]["AAA"] = "Hello"
d["B"]["BB"]["BBB"] = "world"
print(json.dumps(d, indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment