天天看点

Python面向对象编程 - 一个记事本程序范例(二)

给程序加上控制台菜单

menu.py

运行结果:

Notebook Menu

1. Show all Notes 2. Search Notes 3. Add Note 4. Modify Note 5. Quit

Enter an option: 3 Enter a memo: test Your note has been added. ... Enter an option: 3 Enter a memo: hello Your note has been added.

Enter an option: 1 1:   test ********************************* 2:   hello ********************************* ... Enter an option: 2 Search for: hel 2:   hello ********************************* ... Enter an option: 4 Enter a note id: 1 Enter a memo: aa Enter tags: 1 <notebook.Note object at 0x02B80FB0> ... Enter an option: 1 1: 1  aa ********************************* 2:   hello ... Enter an option: 5 Thank you for using your notebook today.