天天看點

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.