python字典查詢功能
阿新 • • 發佈:2018-12-11
pass change strip 刪除 () == python字典 clas rip
def fetch(data): print(‘ 查詢功能‘) print(‘用戶數據是‘,data) def add(): pass def change(): pass def delete(): pass if __name__ == ‘__main__‘: msg = ‘‘‘ 1: 查詢 2. 添加 3. 修改 4. 刪除 5. 退出 ‘‘‘ msg_dict = { ‘1‘: fetch, ‘2‘: add, ‘3‘: change, ‘4‘: delete } while True: print(msg) choice = input(‘請輸入你的選項:‘).strip() if not choice: continue if choice == ‘5‘: break data = input(‘請輸入你的數據:‘).strip() msg_dict[choice](data)
python字典查詢功能