本文整理汇总了Python中tree.Node.search方法的典型用法代码示例。如果您正苦于以下问题:Python Node.search方法的具体用法?Python Node.search怎么用?Python Node.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.Node
的用法示例。
在下文中一共展示了Node.search方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from tree import Node [as 别名]
# 或者: from tree.Node import search [as 别名]
with open('input.txt') as f:
for line in f:
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: