python面向?qū)ο髮崿F(xiàn)名片管理系統(tǒng)文件版
更新時間:2019年04月26日 10:36:33 作者:惜美人
這篇文章主要為大家詳細介紹了python面向?qū)ο髮崿F(xiàn)名片管理系統(tǒng)文件版,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了python實現(xiàn)名片管理系統(tǒng)源代碼,供大家參考,具體內(nèi)容如下
import os
def print_menu():
print("*"*50)
print(" 名片管理系統(tǒng)")
print(" 1.添加一個新名片")
print(" 2.刪除一個名片信息")
print(" 3.修改一個名片信息")
print(" 4.查找一個名片信息")
print(" 5.顯示添加過的名片信息")
print(" 6.保存添加的名片信息")
print(" 7.退出系統(tǒng)")
print("*"*50)
card_infor = []
def add_new_card_infor():
new_name = input("請輸入要添加的名字:")
new_qq = input("請輸入Qq:")
new_weixin = input("請輸入微信號:")
new_position = input("請輸入工作職位")
new_addr = input("請輸入工作地址")
"""創(chuàng)建一個字典來存放添加的內(nèi)容"""
new_infor = {}
new_infor['name'] = new_name
new_infor['qq'] = new_qq
new_infor['weixin'] = new_weixin
new_infor['position'] = new_position
new_infor['addr'] = new_addr
"""將字典剛?cè)胍粋€列表中"""
global card_infor
card_infor.append(new_infor)
def del_card_infor():
del_name =input("請輸入要刪除的名片")
global card_infor
for temp in card_infor:
if del_name == temp['name']:
print("刪除的名片如下")
card_infor.remove(temp)
print("%s\t\t%s\t\t%s\t\t%s\t\t%s"%(temp['name'],temp['qq'],temp['weixin'],temp['position'],temp['addr']))
else:
print("不存在")
return del_card_infor()
def change_care_infor():
change_name_card = input("請輸入需要修改的名片名字")
global card_infor
for temp in card_infor:
if change_name_card == temp['name']:
new_name = input("請輸入要修改的名字")
new_qq = input("請輸入要修改的qq")
new_weixin = input("請輸入要修改的微信")
new_position = input("請輸入要修改的職業(yè)")
new_addr = input("請輸入要修改的地址")
temp['name'] = new_name
temp['qq'] = new_qq
temp['weixin'] = new_weixin
temp['position'] = new_position
temp['addr'] = new_addr
print("修改成功")
break
else:
print("您要修改的名片不存在")
def find_card_infor():
global card_infor
find_name = input("請輸入要在查找的內(nèi)容\n")
find = 0
for temp in card_infor:
if find_name == temp['name']:
print("查詢成功\n")
print("%s\t\t%s\t\t%s\t\t%s\t\t%s"%(temp['name'],temp['qq'],temp['weixin'],temp['position'],temp['addr']))
find = 1
break
else:
print("您要查詢的名片不存在,請重新輸入")
return find_card_infor()
def display_card_infor():
global card_infor
print("姓名\t\tQQ\t\t微信\t\t工作\t\t住址")
for temp in card_infor:
print("%s\t\t%s\t\t%s\t\t%s\t\t%s"%(temp['name'],temp['qq'],temp['weixin'],temp['position'],temp['addr']))
def save_card_infor():
global card_infor
f = open("save_card.data","w")
f.write(str(card_infor))
f.close()
def load_card_infor():
"""恢復保存的信息"""
global card_infor
try:
f = open('save_card.data')
card_infor = eval(f.read())
f.close()
except Exception:
pass
def main():
load_card_infor()
"""把恢復保存的信息加載到程序中"""
print_menu()
"""加載首頁操作頁面"""
while True:
num = int(input("請輸入你要選擇的功能序號"))
if(num==1):
add_new_card_infor()
elif(num==2):
del_card_infor()
elif(num==3):
change_care_infor()
elif(num==4):
find_card_infor()
elif(num==5):
display_card_infor()
elif(num==6):
save_card_infor()
elif(num==7):
break
else:
print("輸入有誤,請重新輸入")
print()
if __name__ == "__main__":
main()
運行界面


以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
探索Python函數(shù)調(diào)用為何加速代碼執(zhí)行原理
Python 作為一種解釋型語言,其執(zhí)行速度相對于編譯型語言可能會較慢,然而,在Python中,通常觀察到代碼在函數(shù)中運行得更快的現(xiàn)象,這個現(xiàn)象主要是由于函數(shù)調(diào)用的內(nèi)部優(yōu)化和解釋器的工作方式導致的,本文將深入探討這個現(xiàn)象,并通過詳細的示例代碼進行解釋2024-01-01
Python 數(shù)據(jù)可視化pyecharts的使用詳解
這篇文章主要介紹了Python 數(shù)據(jù)可視化pyecharts的使用詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-06-06

