python 장식 기 연습

1746 단어
'''
      

        :   ,  
    :
1、    
2、      
'''
info_dict = {}


def add_info():
    new_info = input('           、  ,  ’,‘    ')
    new_list = new_info.split(',')
    info_dict[new_list[0]] = new_list[1]


#   、         ,            ,     dict       
def find_info(fn):
    def inner(info_key):
        # info_key = input('          :')
        if info_key in info_dict:
            print('      :{},  :{}'.format(info_key, info_dict[info_key]))
            fn(info_key)
        else:
            print('     ')

    return inner


@find_info
def delete_ele(info_key):
    info_dict.pop(info_key)


@find_info
def change_ele(info_key):
    phone = input('         :')
    info_dict[info_key] = phone


@find_info
def find_ele(info_key):
    pass


while True:
    print('1、  ')
    print('2、  ')
    print('3、  ')
    print('4、  ')
    print('5、    ')
    print('6、  ')
    i = int(input('         :'))
    if i == 1:
        add_info()
        continue
    elif i == 2:
        info_key = input('          :')
        delete_ele(info_key)
        continue
    elif i == 3:
        info_key = input('          :')
        change_ele(info_key)
        continue
    elif i == 4:
        info_key = input('          :')
        find_ele(info_key)
        continue
    elif i == 5:
        print(info_dict)
        continue
    elif i == 6:
        conditions = input('        ?(  yes or no)')
        if conditions.lower() == 'yes':
            break
        elif conditions.lower() == 'no':
            continue
    else:
        continue

좋은 웹페이지 즐겨찾기