名片管理系统v1.1(tools)

时间:2023-10-31 20:24:50
cords_list = []

def show_cords():

    print("*"*80)
print("欢迎使用【名片管理系统】v.1.1")
print("")
print("1.新建名片")
print("2.显示全部")
print("3.查询名片")
print("")
print("0.退出系统")
print("*"*80) def new_cords():
# cords_name = input("请输入姓名: ")
# cords_phone = input("请输入电话: ")
# cords_profession = input("请输入职业: ")
# cords_email = input("请输入邮箱: ")
print("你选择的操作是:1")
print("-"*80)
print("功能:新建名片")
cords_dict = {"cords_name":input("请输入姓名: "),
"cords_phone":input("请输入电话: "),
"cords_profession":input("请输入职业: "),
"cords_email":input("请输入邮箱: ")} print("成功添加 %s 的名片" % cords_dict["cords_name"] ) cords_list.append(cords_dict) def show_all():
print("你选择的操作是: 2")
print("功能:显示全部")
if len(cords_list) == 0:
print("没有名片")
return
show_head() for cords_dict in cords_list:
show_print(cords_dict) print("-"*80) def show_head(): print("^"*80) for name in ["姓名", "电话", "职业", "邮箱"]:
print(name, end="\t\t\t\t")
print("")
print("-"*80) def show_print(cords_dict): print("%s\t\t\t\t%s\t\t\t\t%s\t\t\t\t%s" % (cords_dict["cords_name"],
cords_dict["cords_phone"],
cords_dict["cords_profession"],
cords_dict["cords_email"])) def refer_cords():
# pass print("你选择的操作是:3")
print("功能:搜索名片")
print("^"*80) find_name = input("请输入要搜索的姓名: ") for cords_dict in cords_list: if cords_dict["cords_name"] == find_name: show_head() show_print(cords_dict) cords_alter_remove(cords_dict) break else:
print("没有找到啊,大哥") def cords_alter_remove(cords_dict):
print("1.修改,2.删除,3,返回")
input_alter_remove = input("请选择: ") if input_alter_remove == "1": cords_dict["cords_name"] = input_dict(cords_dict["cords_name"],input("姓名[回车不修改]: "))
cords_dict["cords_phone"] = input_dict(cords_dict["cords_phone"],input("电话[回车不修改]: "))
cords_dict["cords_profession"] = input_dict(cords_dict["cords_profession"],input("职业[回车不修改]: "))
cords_dict["cords_email"] = input_dict(cords_dict["cords_email"],input("邮箱[回车不修改]: ")) elif input_alter_remove == "2": cords_list.remove(cords_dict) def input_dict(cords_ret,input_alter): if len(input_alter) > 0: return input_alter else: return cords_ret