import card_tools
while True:
card_tools.men_card()
ope1 = input("请选择操作功能:")
if ope1 == "1":
card_tools.new_card()
elif ope1 =="2":
card_tools.find_all()
elif ope1 == "3":
# card_tools.find_card()
card_tools.searth_card()
elif ope1 == "0":
print("退出程序,欢迎下次再次使用")
break
else:
print("操作有误,请从新输入")
def searth_card():
print("*" * 50)
print("查找名片")
find_name = input("请输入你要查找的名字:")
for mem_dic in card_list:
if mem_dic["name"] == find_name:
print("姓名\t\t\t年龄\t\t\t体重")
print("=" * 50)
print("%s\t\t%s\t\t%s" % (mem_dic["name"], mem_dic["age"], mem_dic["weight"]))
print("*" * 50)
deal_card(mem_dic)
break
else:
print("未找到%s" % find_name)
def deal_card(mem_dic):
print(mem_dic)
print("-"*50)
action = input("请输入你要执行的操作:"
"[1]修改名片 [2]删除名片 [0]返回上级菜单")
if action == "1":
mem_dic["name"] = card_info(mem_dic["name"],"名字:")
mem_dic["age"] = card_info(mem_dic["age"],"年龄:")
mem_dic["weight"] =card_info(mem_dic["weight"],"体重:")
print("%s修改名片成功!" % mem_dic["name"])
elif action == "2":
card_list.remove(mem_dic)
print("删除名片成功!")
def card_info(dict_value,tip_message):
resut_str = input(tip_message)
if len(resut_str)>0:
return resut_str
else:
return dict_value |
|