树每每要比python内置的dict类慢一些,可是它中的全部数据都是按照某个关键词进行排序的,故在某些状况下是必须使用的。python
python中的二叉树模块内容:git
from bintrees import RBTree btree = RBTree() btree.insert('111',"first") btree.insert('333', "second") btree.insert('2222', "thirdly") print btree # result : RBTree({'111': 'first', '2222': 'thirdly', '333': 'second'})
其余API看源码或官方文档: https://github.com/mozman/bintreesgithub