2021-04-28python名片管理系统
作者:互联网
def display_menu(): print("-" * 30) print("名片管理系统 v8.8") print("1.添加名片") print("2.删除名片") print("3.修改名片") print("4.查询名片") print("5.获取所有名片信息") print("6.退出系统") print("-" * 30) name_list=[] ##新增名片 def add_info(): new_name = input("请输入姓名:") name_list.append(new_name) ##打印所有名片 def print_all_info(): print("="*30) for info in name_list: print(info) print("="*30) ##查找名片 def find_card_info(): find_name = input("请输入要查找的姓名:") find_flag = 0 for i in range(len(name_list)): if find_name == name_list[i]: print(find_name) find_flag = 1 break if find_flag == 0: print("不能找到这个人") ##删除名片 def del_info(): del_name = input("请输入要删除的姓名:") for j in range(len(name_list)): if del_name == name_list[j]: name_list.remove(name_list[j]) break print("删除成功!") ##修改名片 def update_info(): update_name = input("请输入要修改的姓名:") upadte_flag = 0 for n in range(len(name_list)): if update_name in name_list: upadte_flag = 1 name_list.remove(update_name) update_after = input("把{}修改为:".format(update_name)) name_list.append(update_after) print("修改成功!") if upadte_flag == 0: print("不能找到这个人") ##循环 i = 0 while i <1: display_menu() def get_choice(): selected_key = input("请输入选择的序号:") return int(selected_key) key = get_choice() if key == 1: add_info() elif key == 2: del_info() elif key == 3: update_info() elif key == 4: find_card_info() elif key == 5: print_all_info() elif key == 6: print("已经退出系统,欢迎下次使用!") break else: print("输入有误,请重新输入")
标签:名片,name,04,list,update,2021,print,28python,find 来源: https://blog.csdn.net/qq_53791649/article/details/116245989