开发者

How to display hierarchy levels with text

As the title says. It's a tree data structure that I need to display using only text.

--something

----like

----thi开发者_如何学Pythons

------but more visually

--------understandable

What is the de facto way to do this as used maybe by CLIs etc?


There is a property on the TreeNode class called level. You could loop through all nodes and add a number of tab characters to the string for the node based on level. This would then indent your text according to the level of the node in the string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜