#usr/bin/python #-*-coding:utf-8-*- class Tree: childToParent=None parentToChildren=None #获取父节点 def add(self,parent,child): if self.childToParent is None: self.childToParent={child:parent} else: self.childToParent[child]=parent if self.parentToChildren is None: self.parentToChildren={parent:[]} children=self.parentToChildren.get(parent,[]) if len(children)==0: self.parentToChildren[parent]=children children.append(child) # 获取所有子节点
python--获取节点
最新推荐文章于 2022-11-23 20:33:55 发布