名片管理系统

card_lists = []
headline = ['name','tel','qq number','e-mail']
print('welcome to idcard management system')
# todo define 5 functions:
# 1.define menu imfomation:
def notice():
    print('*'*65)
    print("1.create a new idcard")
    print("2.show all ids")
    print("3.find idcard")
    print("0.exit"+'\n')
    print('*'*65)
# 2.define the function of creat new idcard
def create_new():
    name = input('input your name:')
    tel = input("input your tel:")
    qq_num = input('input your qq number:')
    email = input('input your e-mail:')
    id_card ={'name':name,'tel':tel,"qq_num":qq_num,'email':email}
    card_lists.append(id_card)
# 3.define the function of revise idcard
def revise_id():
    name = input('input your new name:')
    tel = input("input your new tel:")
    qq_num = input('input your new qq number:')
    email = input('input your new e-mail:')
    id_card ={'name':name,'tel':tel,"qq_num":qq_num,'email':email}
    return id_card
# 4.define the function of show all idcards
def show_all():
    print('-'*65)
    for item in headline:
        print(item.center(12),end='\t')
    print('\n',end='')
    for id_card in card_lists:
        for key in id_card:
            print(id_card[key].center(12),end='\t')
        print('\n',end='')
    print('-'*65)
# 5.define the function of find idcard
def find_id():
    global card_lists
    name = input('input the name you wanna search:')
    for id_card in card_lists:
        if id_card['name'] == name:
            print('-'*65)
            for item in headline:
                print(item.center(12),end='\t')
            print('\n',end='')
            for key in id_card:
                print(id_card[key].center(12),end='\t')
            print('\n')
            print('0: delete a idcard,1: revise a idcard')
            print('-'*65)
            operation_choice = input()
            if operation_choice == '0':
                del_name = input('input name to delete:')
                for id_card1 in card_lists:
                    if del_name == id_card1['name']:
                        del card_lists[card_lists.index(id_card1)]
                break
            elif operation_choice == '1':
                revise_name = input('input name to revise:')
                new_idcard = revise_id()
                for id_card1 in card_lists:
                    if revise_name == id_card1['name']:
                        revise_idcard = id_card1
                card_lists[card_lists.index(revise_idcard)] = new_idcard
                break
            else:
                break
    else:
        print('not exist,please retry')
# main function
while True:
    notice()
    usr_input = eval(input("please select operate function:"))
    if usr_input != 0:
        print('Your selection is {}'.format(usr_input))
    if usr_input == 1:
        print('creat a new idcard')
        create_new()
    elif usr_input == 2:
        print('show all idcards')
        show_all()
    elif usr_input == 3:
        find_id()
    #if 0 then exit sys
    elif usr_input == 0:
        print('quit idcard management system')
        quit()
    else:
        print("no this selecton,please retry")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值