名片管理系統(添加及查詢功能)
阿新 • • 發佈:2018-05-03
python
#_*_ conding:utf-8 _*_
#1.打印功能提示
print("="*50)
print(" 名片管理系統 V1.0")
print(" 1:添加一個新的名片")
print(" 2:刪除一個名片")
print(" 3:修改一個名片")
print(" 4:查詢一個名片")
print(" 5:查詢所有的名片")
print(" 6:退出系統")
print("="*50)
#用來存儲名片
card_infors = []
#2.獲取用戶的選擇
while True:
num = int(input("請輸入功能序號:"))
#3.根據用戶的選擇,執行對應的功能
if num==1:
new_name = input("請輸入要添加的名字:")
new_qq = input("請輸入要添加的QQ:")
new_weixin = input("請輸入要添加的微信:")
new_addr = input("請輸入要添加的地址:")
#定義一個新的字典用來存儲一個新的名片
new_infor = {}
new_infor[‘name‘] = new_name
new_infor[‘qq‘] = new_qq
new_infor[‘weixin‘] = new_weixin
new_infor[‘addr‘] = new_addr
#將字典添加到列表中
card_infors.append(new_infor)
elif num==2:
pass
elif num==3:
pass
elif num==4:
find_name = input("請輸入你要查找的名字:")
find_flag = 0 #默認表示沒有找到名片
for temp in card_infors:
if find_name == temp[‘name‘]:
print("確認過眼神,你找到了對的人!")
print("姓名\tQQ\t微信\t地址")
print("%s\t%s\t%s\t%s"%(temp[‘name‘],temp[‘qq‘],temp[‘weixin‘],temp[‘addr‘]))
find_flag=1 #1表示找到此人
break
if find_flag == 0:
print("緣分未到,查無此人。")
elif num==5:
print("姓名\tQQ\t微信\t地址")
for temp in card_infors:
print("%s\t%s\t%s\t%s"%(temp[‘name‘],temp[‘qq‘],temp[‘weixin‘],temp[‘addr‘]))
elif num==6:
break
else:
print("您的輸入有誤,請重新輸入")
[輸出結果]
[root@localhost 02-data_type]# python easy_card_manag.py ================================================== 名片管理系統 V1.0 1:添加一個新的名片 2:刪除一個名片 3:修改一個名片 4:查詢一個名片 5:查詢所有的名片 6:退出系統 ================================================== 請輸入功能序號:1 請輸入要添加的名字:michael 請輸入要添加的QQ:123 請輸入要添加的微信:1234 請輸入要添加的地址:香蜜湖 請輸入功能序號:1 請輸入要添加的名字:陳冠融 請輸入要添加的QQ:12345 請輸入要添加的微信:321 請輸入要添加的地址:香蜜湖 請輸入功能序號:4 請輸入你要查找的名字:陳冠融 確認過眼神,你找到了對的人! 姓名 QQ 微信 地址 陳冠融 12345 321 香蜜湖 請輸入功能序號:4 請輸入你要查找的名字:michael 確認過眼神,你找到了對的人! 姓名 QQ 微信 地址 michael 123 1234 香蜜湖 請輸入功能序號:5 姓名 QQ 微信 地址 michael 123 1234 香蜜湖 陳冠融 12345 321 香蜜湖 請輸入功能序號:6
簡單的名片管理系統,添加名片及查詢名片功能;後續會把增刪改查功能完善,盡情期待吧!
名片管理系統(添加及查詢功能)