将嵌套列表转换为树形图片
我有一个 JSON/Python 嵌套列表,它代表一棵树,每个项目都是一个节点,如果节点是一个列表,那么它就是一个子树。
有什么简单的方法可以从中创建一些令人愉悦的图形吗?
[[1, [[4, [[7], [8], [9]]], [5, [[7], [8], [9]]], [6, [[7], [8], [9]]]]], [2, [[4, [[7], [8], [9]]], [5, [[7], [8], [9]]], [6, [[7], [8], [9]]]]], [3, [[4, [[7], [8], [9]]], [5, [[7], [8], [9]]], [6, [[7], [8], [9]]]]]]
这是 JSON 本身 的更整洁的布局,这对我没有太大帮助。
I have a JSON/Python nested list which represents a tree, each item being a node, if the node is a list, it is a subtree.
Any easy way to create some pleasing graphics out of that?
[[1, [[4, [[7], [8], [9]]], [5, [[7], [8], [9]]], [6, [[7], [8], [9]]]]], [2, [[4, [[7], [8], [9]]], [5, [[7], [8], [9]]], [6, [[7], [8], [9]]]]], [3, [[4, [[7], [8], [9]]], [5, [[7], [8], [9]]], [6, [[7], [8], [9]]]]]]
This is a neater layout of the JSON itself, which does not help me too much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查看 GraphViz 使用其简单的点表示法制作基本图形图像。然后在 python 中,您可以创建一个非常简单的递归函数来生成点文件并构建图形。
You could look into GraphViz for making basic graph images using its simple dot notation. Then in python you could make a really simple recursive function that generates the dot file and builds the graph.