本文整理汇总了Python中tree.Node.data方法的典型用法代码示例。如果您正苦于以下问题:Python Node.data方法的具体用法?Python Node.data怎么用?Python Node.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.Node
的用法示例。
在下文中一共展示了Node.data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_tree
# 需要导入模块: from tree import Node [as 别名]
# 或者: from tree.Node import data [as 别名]
def make_tree(self):
"""
Constructs the tree by iterating nodesList.
"""
while self.nodesList:
row = self.nodesList.pop(0)
nodeId = self.idFn(row)
#print 'make_tree,row is %s, node id is %s'%(row,nodeId)
try:
node = self.rootNode.get_child_by_id(nodeId)
except:
node = None
if not node:
node = Node(nodeId)
node.data = row
#print 'make_tree,created a new node, id is ',node.id
parentId = self.pidFn(row)
# creates it's parent node and recursivelly creates the ancestor nodes of this node.
self.parent(parentId, node)
#print '****make_tree is end, maked branch is ******\n',self.rootNode
#print 70*'-'
return
示例2: make_node
# 需要导入模块: from tree import Node [as 别名]
# 或者: from tree.Node import data [as 别名]
def make_node(self,nodeId):
"""
Filters the row from self.nodesList by nodeId,
and create a new Node.
After node's creation,the row will be removed from the nodesList.
"""
row = filter( lambda i: self.idFn(i)==nodeId , self.nodesList)[0]
#print 'make_node,row is %s, node id is %s'%(row,nodeId)
node = Node(nodeId)
node.data = row
self.nodesList.remove(row)
return node