|
|
|
|
|
card_list = []
|
|
|
|
|
|
def show_menu():
|
|
|
|
|
|
print("*" * 50)
|
|
|
print("欢迎使用【名片管理系统】".center(40) + "") # 居中菜单标题
|
|
|
print("1.新建名片")
|
|
|
print("2.显示全部名片")
|
|
|
print("3.查询名片")
|
|
|
print("4.退出系统")
|
|
|
print("*" * 50)
|
|
|
|
|
|
|
|
|
def new_a_card():
|
|
|
|
|
|
print("=" * 50)
|
|
|
print("新增名片 请输入信息".center(70))
|
|
|
|
|
|
name = input("请输入您的姓名:")
|
|
|
phone = input("请输入您的电话:")
|
|
|
qq = input("请输入您的qq号:")
|
|
|
email = input("请输入您的邮箱:")
|
|
|
|
|
|
|
|
|
information = {
|
|
|
"姓名": name,
|
|
|
"电话": phone,
|
|
|
"qq号": qq,
|
|
|
"email": email
|
|
|
}
|
|
|
|
|
|
|
|
|
card_list.append(information)
|
|
|
|
|
|
|
|
|
print("添加%s的名片成功" % name)
|
|
|
|
|
|
|
|
|
def show_all_cards():
|
|
|
|
|
|
print("=" * 50)
|
|
|
print("显示全部名片".center(70))
|
|
|
|
|
|
|
|
|
if len(card_list) == 0:
|
|
|
print("名片系统为空")
|
|
|
return
|
|
|
|
|
|
|
|
|
print("姓名\t\t\t\t电话\t\t\t\tqq号\t\t\t\temail")
|
|
|
print("=" * 50)
|
|
|
|
|
|
|
|
|
for i in card_list:
|
|
|
print("%s\t\t\t\t%s\t\t\t\t%s\t\t\t\t%s" % (i["姓名"], i["电话"], i["qq号"], i["email"]))
|
|
|
|
|
|
|
|
|
print("=" * 50)
|
|
|
|
|
|
|
|
|
def search_card():
|
|
|
|
|
|
print("=" * 50)
|
|
|
print("查询名片".center(70))
|
|
|
|
|
|
|
|
|
if len(card_list) == 0:
|
|
|
print("名片系统为空")
|
|
|
return
|
|
|
|
|
|
|
|
|
search_name = input("请输入要查询的姓名:")
|
|
|
|
|
|
|
|
|
for i in card_list:
|
|
|
|
|
|
if i["姓名"] == search_name:
|
|
|
print("姓名\t\t\t\t电话\t\t\t\tqq号\t\t\t\temail")
|
|
|
print("=" * 50)
|
|
|
print("%s\t\t\t\t%s\t\t\t\t%s\t\t\t\t%s" % (i["姓名"], i["电话"], i["qq号"], i["email"]))
|
|
|
print("=" * 50)
|
|
|
|
|
|
# 三种操作
|
|
|
deal_search_one(i)
|
|
|
break
|
|
|
else:
|
|
|
print("查无此人")
|
|
|
|
|
|
|
|
|
def deal_search_one(search_dictionary):
|
|
|
|
|
|
while True:
|
|
|
function_choice = input("请输入想要执行的操作:1.修改 2.删除 3.返回上级目录")
|
|
|
|
|
|
if function_choice == "1":
|
|
|
print("修改名片".center(70))
|
|
|
search_dictionary["姓名"] = new_input(search_dictionary["姓名"], "姓名:")
|
|
|
search_dictionary["电话"] = new_input(search_dictionary["电话"], "电话:")
|
|
|
search_dictionary["qq号"] = new_input(search_dictionary["qq号"], "qq号:")
|
|
|
search_dictionary["email"] = new_input(search_dictionary["email"], "邮箱:")
|
|
|
break
|
|
|
|
|
|
elif function_choice == "2":
|
|
|
print("删除名片".center(70))
|
|
|
card_list.remove(search_dictionary)
|
|
|
break
|
|
|
|
|
|
elif function_choice == "3":
|
|
|
return
|
|
|
|
|
|
else:
|
|
|
print("没有此操作 请重新输入")
|
|
|
|
|
|
print("处理完成")
|
|
|
|
|
|
|
|
|
def new_input(value, tip_message):
|
|
|
|
|
|
input_thing = input(tip_message)
|
|
|
|
|
|
|
|
|
if len(input_thing) > 0:
|
|
|
return input_thing
|
|
|
else:
|
|
|
return value |