本文主要是介绍综合性练习,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
名片管理系统
综合性项目实现—详细请点这里
dict = {} # 定义一个空字典,用于存储信息。
list = [] # 定义一个列表,存储name值
list1 = [] #存储age值
list2 = [] #存储phone值
def people_tips(): #提示print("*****" * 10)print("欢迎使用【名片管理系统】")print("1.新建名片")print("2.显示全部")print("3.查询名片")print("0.退出系统")print("*****" * 10)def people_print(dict): #显示全部len1 = len(dict["name"]) # 获取名片人数for i in range(len1):for j in dict.keys():print(dict[j][i], end="\t")print()def people_edit(list): #修改名片print("请输入要修改的名片姓名:")name = input()for index, values in enumerate(list):if name == values:print("请输入修改后的年龄:")age = input()dict["age"][index] = ageprint("请输入修改后的手机号:")phone = input()dict["phone"][index] = phonedef people_find(dict,list): #查询名片print("请输入要查询的名片姓名:")name = input()print("姓名 年龄 手机号")for index, values in enumerate(list):if name == values:print(dict["name"][index],end='\t')print(dict["age"][index], end='\t')print(dict["phone"][index])def people_pop(dict,list): #删除名片name = input("请输入要删除的名片名字:")for index, values in enumerate(list):if name == values:dict["name"].pop(index)dict["age"].pop(index)dict["phone"].pop(index)while True:people_tips()x = int(input("请输入数字:"))if x == 1: #新建名片print("**" * 20)print("功能,新建名片")print("**" * 20)print("请输入名字:")name = input()list.append(name)dict["name"] = listprint("请输入年龄:")age = int(input())list1.append(age)dict["age"] = list1print("请输入手机号:")phone = input()if len(phone) != 11:print("手机号格式不对,请重新输入:")phone = input()list2.append(phone)dict["phone"] = list2else:list2.append(phone)dict["phone"] = list2print(dict)if x == 2: #显示全部print("**"*20)print("功能:显示全部")print("**" * 20)print("姓名 年龄 手机号")people_print(dict)if x == 3: #查询名片while True:print("**"*20)print("0.退出系统")print("1.修改名片")print("2.查看名片")print("3.删除名片")print("**" * 20)y = int(input("请输入数字:"))if y == 0:breakif y == 1:people_edit(list)if y == 2:people_find(dict,list)if y == 3:people_pop(dict,list)if x == 0:print("**" * 20)print("功能,退出系统")print("**" * 20)break
这篇关于综合性练习的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!