GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — article/corepython2ndsourcecode/ch06/queue.py at master · pythonpeixun/article Expand file tree/ Copy pathqueue.pyMore file actions 66 lines (51 loc) · 1.25 KB / Copy pathqueue.pyFile metadata and controls66 lines (51 loc) · 1.25 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 #!/usr/bin/env python # coding:utf-8 ''' 欢迎参加黄哥python远程视频培训, 帮你完成从不会写代码到会写代码解决问题的过渡。 https://github.com/pythonpeixun/article/blob/master/index.md 咨询qq:1465376564 黄哥Python培训 黄哥改写 Python 3 P148页代码 ''' queue = [] def enQ(): queue.append(input('Enter new queue element: ')) def deQ(): if len(queue) == 0: print('Cannot dequeue from empty queue!') else: print('Removed [', queue.pop(0), ']') def viewQ(): print(str(queue)) def showmenu(): prompt = """ (E)nqueue (D)equeue (V)iew (Q)uit Enter choice: """ done = 0 while not done: chosen = 0 while not chosen: try: choice = input(prompt)[0] except (IndexError, EOFError, KeyboardInterrupt): choice = 'q' print('\nYou picked: [%s]' % choice) if choice not in 'devq': print('invalid option, try again') else: chosen = 1 if choice == 'q': done = 1 if choice == 'e': enQ() if choice == 'd': deQ() if choice == 'v': viewQ() if __name__ == '__main__': showmenu() |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |