十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
编写程序,完成“名片管理器”项目
需要完成的基本功能:
程序运行后,除非选择退出系统,否则重复执行功能
mingp.py
# 名片类:(参数) # # 添加名片功能 # # 删除名片功能: # # 修改名片功能: # # 查询名片功能: class MingPian(): def __init__(self,all_dict,name,age): self.all_dict=all_dict self.name=name self.age=age def tianjia(self): my_dict = {"name": self.name, "age": self.age} self.all_dict[self.name]=my_dict print("添加名片成功....") return self.all_dict # print(self.all_dict) #测试添加函数可否正常执行 def shanchu(self): if self.name in self.all_dict: del self.all_dict[self.name] print("删除成功") else: print("输入名字有误") return self.all_dict def xiugai(self): if self.name in self.all_dict: self.age = input("请输入修改后的年龄:") self.all_dict[self.name]["age"] = self.age print("修改成功") else: print("输入名字有误") return self.all_dict def chaxun(self): if self.name in self.all_dict: n = self.all_dict[self.name]["name"] a = self.all_dict[self.name]["age"] print("姓名:%s 年龄:%s" % (n, a)) else: print("输入名字有误") #test # all_dict = {} # MingPian(all_dict,'xiaoming','20').tianjia()