python面向?qū)ο髮?shí)現(xiàn)名片管理系統(tǒng)文件版
更新時(shí)間:2019年04月26日 10:36:33 作者:惜美人
這篇文章主要為大家詳細(xì)介紹了python面向?qū)ο髮?shí)現(xiàn)名片管理系統(tǒng)文件版,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了python實(shí)現(xiàn)名片管理系統(tǒng)源代碼,供大家參考,具體內(nèi)容如下
import os def print_menu(): print("*"*50) print(" 名片管理系統(tǒng)") print(" 1.添加一個(gè)新名片") print(" 2.刪除一個(gè)名片信息") print(" 3.修改一個(gè)名片信息") print(" 4.查找一個(gè)名片信息") 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)建一個(gè)字典來存放添加的內(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è)胍粋€(gè)列表中""" 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(): """恢復(fù)保存的信息""" global card_infor try: f = open('save_card.data') card_infor = eval(f.read()) f.close() except Exception: pass def main(): load_card_infor() """把恢復(fù)保存的信息加載到程序中""" 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()
運(yùn)行界面
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Pycharm中運(yùn)行程序在Python?console中執(zhí)行,不是直接Run問題
這篇文章主要介紹了Pycharm中運(yùn)行程序在Python?console中執(zhí)行,不是直接Run問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-07-07python 獲取文件下所有文件或目錄os.walk()的實(shí)例
下面小編就為大家分享一篇python 獲取文件下所有文件或目錄os.walk()的實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-04-04利用Python實(shí)現(xiàn)某OA系統(tǒng)的自動定位功能
這篇文章主要介紹了利用Python實(shí)現(xiàn)某OA系統(tǒng)的自動定位功能,本文通過圖文實(shí)例相結(jié)合給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-05-05詳解Python小數(shù)據(jù)池和代碼塊緩存機(jī)制
這篇文章主要介紹了詳解Python 小數(shù)據(jù)池和代碼塊緩存機(jī)制的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用python,感興趣的朋友可以了解下2021-04-04Windows系統(tǒng)下cython_bbox庫的正確安裝步驟
Cython-bbox一般無法直接通過pip直接安裝,那么如何安裝呢?下面這篇文章主要給大家介紹了關(guān)于Windows系統(tǒng)下cython_bbox庫的正確安裝步驟,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下2023-05-05關(guān)于TensorBoard的使用以及遇到的坑記錄
這篇文章主要介紹了關(guān)于TensorBoard的使用以及遇到的坑記錄,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-09-09