码迷,mamicode.com
首页 > 编程语言 > 详细

python字典查询功能

时间:2018-12-11 11:25:44      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:class   input   not   ict   输入   break   ice   etc   style   

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字典查询功能

标签:class   input   not   ict   输入   break   ice   etc   style   

原文地址:https://www.cnblogs.com/majianyu/p/10100367.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!