当前位置: 首页>>代码示例>>Python>>正文


Python Tree.rsearch方法代码示例

本文整理汇总了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
开发者ID:Mondego,项目名称:pyreco,代码行数:33,代码来源:allPythonContent.py

示例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)
开发者ID:AgusRumayor,项目名称:pyTree,代码行数:33,代码来源:family_tree.py

示例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')
开发者ID:techdragon,项目名称:pyTree-1,代码行数:33,代码来源:family_tree.py

示例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")
开发者ID:jeffg2k,项目名称:pyTree,代码行数:32,代码来源:family_tree.py


注:本文中的treelib.Tree.rsearch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。