# 界面 def menu(): print("1.添加名片") print("2.删除名片") print("3.修改名片") print("4.查询名片") print("5.获取所有名片名片") print("6.推出系统") # # 添加 def add(list): print("添加") map={"name":"","age":"","id":"","address":""} print("输入姓名:") name=input() print("输入年龄:") age=input() print("输入id:") id=input() print("输入住址") address=input() map['name']=name map['age']=age map['id']=id map['address']=address list.append(map) print("添加成功!") return list # # 删除 def delete(name,list): print("删除") n=0 for i in list: if name==i['name']: del list[n] print("删除成功!") n=n+1 # # 修改 def updata(name,list): print("修改") for i in list: if name==i['name']: print("输入要修改的元素") print("1.年龄") print("2.id") print("3.地址") n=int(input()) if n==1: print("输入修改的年龄:") age=input() i['age']=age if n==2: print("输入修改的id:") id=input() i['id']=id if n==3: print("输入修改的地址") address=input() i['address']=address print("修改完成!") break; # # 查询 def find(name,list): print("查询") for i in list: if i['name']==name: print(i) break # # 查询所有 def findall(list): print("所有员工信息如下") for i in list: print(i) map1={'name':'zhansan1','age':"21",'id':"1",'address':'北京'} map2={'name':'zhansan2','age':"22",'id':"2",'address':'上海'} map3={'name':'zhansan3','age':"23",'id':"3",'address':'邵阳'} map4={'name':'zhansan4','age':"24",'id':"4",'address':'兰州'} list=[map1,map2,map3,map4] menu() n=int(input()) while 1 : if n==1: add(list) if n==2: print("输入你要删除的员工姓名:") name=input() delete(name,list) if n==3: print("请输入你要修改员工的姓名:") name=input() updata(name,list) if n==4: print("输入输入你要查询的员工姓名:") name=input() find(name,list) if n==5: findall(list) if n==6: print("退出名片管理系统!") break; menu() n = int(input())