本文整理汇总了Python中notebook.Notebook.modify_tag方法的典型用法代码示例。如果您正苦于以下问题:Python Notebook.modify_tag方法的具体用法?Python Notebook.modify_tag怎么用?Python Notebook.modify_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notebook.Notebook
的用法示例。
在下文中一共展示了Notebook.modify_tag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from notebook import Notebook [as 别名]
# 或者: from notebook.Notebook import modify_tag [as 别名]
class Menu:
"""Dislay a menu and respond to choices when run."""
def __init__(self):
self.notebook = Notebook()
self.choices = {
"1":self.show_notes,
"2":self.search_notes,
"3":self.add_note,
"4":self.modify_note,
"5":self.quit
}
def display_menu(self):
print("""
Notebook Menu:
1. Show Notes
2. Search Notes
3. Add Note
4. Modify Note
5. Quit
""")
def run(self):
"""Display the menu and run choices."""
while True:
self.display_menu()
choice = input("Enter an option: ")
action = self.choices.get(choice)
if action:
action()
else:
print("{0} is not a valid choice".format(choice))
def show_notes(self, notes = None):
if not notes:
notes = self.notebook.notes
for note in notes:
print("{0}: {1}\n{2}".format(note.id, note.tags, note.memo))
def search_notes(self):
filter = input("search for: ")
notes = self.notebook.search(filter)
self.show_notes(notes)
def add_note(self):
memo = input("Enter a memo: ")
self.notebook.new_note(memo)
print("Your note has been added.")
def modify_note(self):
id = input("Enter a note Id: ")
memo = input("Enter a memo: ")
tags = input("Enter tags: ")
if memo:
self.notebook.modify_memo(id, memo)
if tags:
self.notebook.modify_tag(id, tags)
def quit(self):
print('Thank you for using your notebook today!')
sys.exit(0)