I am using treelib package to store some tree data struccture!
As I follow the example from the documentation of treelib:
>>> from treelib import Node, Tree
>>> tree = Tree()
>>> tree.create_node("Harry", "harry") # root node
>>> tree.create_node("Jane", "jane", parent="harry")
>>> tree.create_node("Bill", "bill", parent="harry")
>>> tree.create_node("Diane", "diane", parent="jane")
>>> tree.create_node("Mary", "mary", parent="diane")
>>> tree.create_node("Mark", "mark", parent="jane")
>>> tree.show()
However, I cannot display the tree properly in python 3.4, for example I get this
b'Harry'
b'\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Bill'
b'\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Jane'
b' \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Diane'
b' \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Mary'
b' \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Mark'
instead of getting this on python 2.7
Harry
├── Bill
└── Jane
├── Diane
│ └── Mary
└── Mark
Is there anyway to fix this in python 3.4?
Try this:
tree.show(line_type='ascii')