本文整理汇总了Python中treelib.Tree.rsearch方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.rsearch方法的具体用法?Python Tree.rsearch怎么用?Python Tree.rsearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treelib.Tree
的用法示例。
在下文中一共展示了Tree.rsearch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from treelib import Tree [as 别名]
# 或者: from treelib.Tree import rsearch [as 别名]
new_tree.create_node("n1", 1) # root node
new_tree.create_node("n2", 2, parent=1)
new_tree.create_node("n3", 3, parent=1)
tree.paste("jill", new_tree)
tree.show()
print(sep + "They leave after a while:")
tree.remove_node(1)
tree.show()
print(sep + "Now Jill moves to live with Grand-x-father Harry:")
tree.move_node("jill", "harry")
tree.show()
print(sep + "A big family for George to send message to the oldest Harry:")
for node in tree.rsearch("george"):
print(tree[node].tag)
########NEW FILE########
__FILENAME__ = folder_tree
#!/usr/bin/env python
# A file folder scanner contributed by @holger
#
# You can spicify the scanned folder and file pattern by changing rootPath
# and pattern variables
#
__author__ = "holger"
from treelib import tree
import fnmatch
示例2: print
# 需要导入模块: from treelib import Tree [as 别名]
# 或者: from treelib.Tree import rsearch [as 别名]
tree.show(idhidden=False, filter=lambda x: x.identifier != 'diane')
# for node in tree.expand_tree(filter=lambda x: x.identifier != 'diane', mode=Tree.DEPTH):
# print tree[node].tag
print(sep + "Let me introduce Diane family only:")
sub_t = tree.subtree('diane')
sub_t.show()
print(sep + "Children of Diane")
for child in tree.is_branch('diane'):
print(tree[child].tag)
print(sep + "OOhh~ new members join Jill's family:")
new_tree = Tree()
new_tree.create_node("n1", 1) # root node
new_tree.create_node("n2", 2, parent=1)
new_tree.create_node("n3", 3, parent=1)
tree.paste('jill', new_tree)
tree.show()
print(sep + "They leave after a while:")
tree.remove_node(1)
tree.show()
print(sep + "Now Jill moves to live with Grand-x-father Harry:")
tree.move_node('jill', 'harry')
tree.show()
print(sep + "A big family for George to send message to the oldest Harry:")
for node in tree.rsearch('george'):
print(tree[node].tag)
示例3: print
# 需要导入模块: from treelib import Tree [as 别名]
# 或者: from treelib.Tree import rsearch [as 别名]
sub_t = tree.subtree('diane')
sub_t.show()
print('\n')
print("#"*4 + "Children of Diane")
print tree.is_branch('diane')
print('\n')
print("#"*4 + "OOhh~ new members enter Jill's family")
new_tree = Tree()
new_tree.create_node("n1", 1) # root node
new_tree.create_node("n2", 2, parent=1)
new_tree.create_node("n3", 3, parent=1)
tree.paste('jill', new_tree)
tree.show()
print('\n')
print("#"*4 + "We are sorry they are gone accidently :(")
tree.remove_node(1)
tree.show()
print('\n')
print("#"*4 + "Now Jill moves to live with Grand-x-father Harry")
tree.move_node('jill', 'harry')
tree.show()
print('\n')
print("#"*4 + "A big family for George to talk to Grand-x-father Harry")
for node in tree.rsearch('george', filter=lambda x: x != 'harry'):
print node
print('\n')
示例4: print
# 需要导入模块: from treelib import Tree [as 别名]
# 或者: from treelib.Tree import rsearch [as 别名]
print ("\n")
print ("#" * 4 + "OOhh~ new members enter Jill's family")
new_tree = Tree()
new_tree.create_node("n1", 1) # root node
new_tree.create_node("n2", 2, parent=1)
new_tree.create_node("n3", 3, parent=1)
tree.paste("jill", new_tree)
tree.show()
print ("\n")
print ("#" * 4 + "We are sorry they are gone accidently :(")
tree.remove_node(1)
tree.show()
print ("\n")
print ("#" * 4 + "Now Jill moves to live with Grand-x-father Harry")
tree.move_node("jill", "harry")
tree.show()
print ("\n")
print ("#" * 4 + "A big family for George to talk to Grand-x-father Harry")
for node in tree.rsearch("george", filter=lambda x: x.identifier != "harry"):
print node
print ("harry")
print ("\n")