python实现通讯录代码

import time
print("欢迎进入铝铜讯程序".center(25,"*"))
print("1:查询联系人资料".center(25,"*"))
print("2:插入新的用户".center(25,"*"))
print("3:删除已有用户".center(25,"*"))
print("4:退出铝铜讯录程序".center(25,"*"))
dictionary = dict({})
while True:
    instruct_ = int(input("请输入相关指令>:"))
    if instruct_ == 1:
        dict_keys = list(dictionary.keys())
        dict_values = list(dictionary.values())
        print('已有记录的用户:',dict_keys)
        print('该用户的darling:',dict_values)
    elif instruct_ == 2:
        inkeys = input("请输入新的用户:")
        dict_keys_have = list(dictionary.keys())
        for i in dict_keys_have:
            if inkeys == i:
                print(f"error,宁输入的用户在铜讯录已存在 ——>>{i}:{dictionary[i]}")
                change_instruct = input("是否修改用户资料(yes/no):")
                if change_instruct == 'yes' or change_instruct == 'YES':
                    invalues = input("请输入用户的deling:")
                    break
                elif change_instruct == 'no' or change_instruct == 'NO':
                    break
        else:
            invalues = input("请输入用户的deling:")
            dictionary[inkeys] = invalues
    elif instruct_ == 3:
        del_keys = input("请输入要删除的用户:")
        print(f'已删除{del_keys}:',dictionary.pop(del_keys))
    elif instruct_ == 4:
        print('正在退出程序...')
        time.sleep(1.314)
        print('退出成功...')
        break
    else:print('输入指令错误,请重新输入...')

你可能感兴趣的:(python,开发语言,后端)