本文整理汇总了Python中tree.Node.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Node.delete方法的具体用法?Python Node.delete怎么用?Python Node.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.Node
的用法示例。
在下文中一共展示了Node.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from tree import Node [as 别名]
# 或者: from tree.Node import delete [as 别名]
tree.insert(line)
print("1. Print tree\n2. Search node\n3. Delete node\n4. Exit")
ans = True
while ans:
ans = raw_input("What would you like to do? ")
if ans == "1":
print("Tree:")
tree.printTree()
elif ans == "2":
print("Searching node...")
data = raw_input("Enter node data: ")
a = datetime.datetime.now()
print "Node found: ", tree.search(data).data
b = datetime.datetime.now()
print "Found in file: ", search(data)
c = datetime.datetime.now()
print "Search in tree time: ", b - a
print "Search in file time: ", c - b
elif ans == "3":
print("Deletion node...")
data = raw_input("Enter node data: ")
tree.delete(data)
delete(data)
print("Node deleted")
elif ans == "4":
print("Goodbye")
ans = None
else:
print("Not valid choice. Try again")
示例2: test_delete
# 需要导入模块: from tree import Node [as 别名]
# 或者: from tree.Node import delete [as 别名]
def test_delete():
root = Node(8)
root.insert(3)
root.delete(3)
root.delete(8)