card_list = []
def Biao_ti():
print("*" * 50)
print("欢迎使用名片管理系统 V 1.0")
print("")
print("1 新增名片")
print("2 显示全部")
print("3 搜索名片")
print("")
print("0 退出系统")
print("*" * 50)
def new_card():
'''新增卡片'''
print("-" * 50)
print("新增卡片")
name = input("请输入名字:")
Gender = input("请输入性别:")
qq = input("请输入QQ号码:")
emile = input("请输入邮箱地址:")
card_dict = {
"name": name,
"Gender": Gender,
"qq": qq,
"emile": emile
}
card_list.append(card_dict)
print(card_list)
print("您已成功添加% s" % name)
def show_all():
'''展示所有卡片'''
print("-" * 50)
print("显示所有")
if len(card_list) == 0:
print("没有任何内容,请先添加卡片内容!")
return
for name in ["姓名", "性别", "qq ", "邮箱"]:
print(name, end="\t\t")
print("")
for card_dict in card_list:
print("%s\t\t%s\t\t%s\t\t%s" % (card_dict["name"],
card_dict["Gender"],
card_dict["qq"],
card_dict["emile"]))
def sourch_card():
'''搜索名片'''
print("-" * 50)
print("搜索名片")
find_name = input("请输入要查询的姓名:")
for card_dict in card_list:
if card_dict["name"] == find_name:
print("姓名\t\t性别\t\t\t\tQQ\t\t\t\t邮箱")
print("%s\t\t\t%s\t\t\t\t%s\t\t\t\t%s" % (card_dict["name"],
card_dict["Gender"],
card_dict["qq"],
card_dict["emile"]))
deal_dict(card_dict)
break
else:
print("很抱歉没有找到%s" % find_name)
def deal_dict(find_dict):
print(find_dict)
action = input("请输入您要操作的内容: "
"[1] 修改 [2] 删除 [3] 返回上一级")
if action == "1":
find_dict["name"] = card_dict_str(find_dict["name"], "姓名:")
find_dict["Gender"] = card_dict_str(find_dict["Gender"], "性别:")
find_dict["qq"] = card_dict_str(find_dict["qq"], "QQ:")
find_dict["emile"] = card_dict_str(find_dict["emile"], "邮箱:")
print("修改卡片成功")
elif action == "2":
card_list.remove(find_dict)
print("删除卡片内容成功")
else:
print("返回上一级")
def card_dict_str(dict_value, tip_massger):
dict_str = input(tip_massger)
if len(dict_str) > 0:
return dict_str
else:
return dict_value
import cards_tools
while True:
cards_tools.Biao_ti()
ancton=input("请输入你要操作的类型:")
print("你输入的类型是【%s】" % ancton)
if ancton in ("1","2","3"):
if ancton == "1":
cards_tools.new_card()
elif ancton == "2":
cards_tools.show_all()
else:
cards_tools.sourch_card()
elif ancton == "0":
print("欢迎下次光临【名片管理系统】")
break
else:
print("输入错误,请重新输入")