python實現(xiàn)學(xué)生通訊錄管理系統(tǒng)
本文實例為大家分享了python實現(xiàn)學(xué)生通訊錄管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
功能模塊分析:
1.首頁(菜單功能)
2.添加學(xué)生
3.刪除學(xué)生
4.修改學(xué)生
5.統(tǒng)計通訊錄聯(lián)系人人數(shù)
6.獲取所有學(xué)生通訊信息
代碼如下:
def main(): while True: menu() number = int(input("請輸入需要實現(xiàn)的操作的序號:")) if number==1: insert() #添加學(xué)生 if number==2: delete() #刪除學(xué)生 if number==3: modify() #修改學(xué)生 if number==4: count() #統(tǒng)計通訊錄聯(lián)系人人數(shù) if number==5: disply() #獲取所有學(xué)生通訊信息 if number==0: x=input("輸入yes退出系統(tǒng),輸入其他任意字符不退出:") if x == "yes": break studentlist=[] def menu(): Menu = """ ====================學(xué)生通訊錄管理系統(tǒng)-V1.0==================== 1.添加學(xué)生 2.刪除學(xué)生 3.修改學(xué)生 4.統(tǒng)計通訊錄聯(lián)系人人數(shù) 5.獲取所有學(xué)生通訊信息 0.退出系統(tǒng) ===================================================== """ print(Menu) def insert(): while True: studentdict={} studentdict["序號"]=input("請輸入需添加學(xué)生的序號:") studentdict["姓名"]=input("請輸入需添加學(xué)生的姓名:") studentdict["電話"]=input("請輸入需添加學(xué)生的電話:") studentlist.append(studentdict) x = input("輸入no結(jié)束添加學(xué)生,輸入其他任意字符將繼續(xù):") if x=="no": break def delete(): while True: i=input("請輸入需刪除的學(xué)生的序號:") for index,item in enumerate(studentlist): if item["序號"]==i: del studentlist[index] x = input("輸入no結(jié)束刪除學(xué)生,輸入其他任意字符將繼續(xù):") if x == "no": break def modify(): while True: i = input("請輸入需修改的學(xué)生的序號:") for item in studentlist: if item["序號"]==i: item["姓名"]=input("請輸入修改后的學(xué)生的姓名:") item["電話"]=input("請輸入修改后的學(xué)生的電話:") x = input("輸入no結(jié)束修改學(xué)生,輸入其他任意字符將繼續(xù):") if x == "no": break def count(): a=len(studentlist) print("通訊錄共有",a,"位聯(lián)系人") def disply(): print('---------------------------') for studentdict_1 in studentlist: for key,value in studentdict_1.items(): print(key,":",value) print('---------------------------') main()
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
PyCharm提示No Python Interpreter的正確解決辦法
剛學(xué)Python時,拿到一個Python項目,想用pycharm打開運行卻報錯了,這篇文章主要給大家介紹了關(guān)于PyCharm提示No Python Interpreter的正確解決辦法,需要的朋友可以參考下2023-10-10python和flask中返回JSON數(shù)據(jù)的方法
下面小編就為大家整理了一篇python和flask中返回JSON數(shù)據(jù)的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-03-03Python?CNN卷積神經(jīng)網(wǎng)絡(luò)實戰(zhàn)教程深入講解
CNN,即卷積神經(jīng)網(wǎng)絡(luò),主要用于圖像識別,分類。由輸入層,卷積層,池化層,全連接層(Affline層),Softmax層疊加而成。卷積神經(jīng)網(wǎng)絡(luò)中還有一個非常重要的結(jié)構(gòu):過濾器,它作用于層與層之間(卷積層與池化層),決定了怎樣對數(shù)據(jù)進(jìn)行卷積和池化2022-12-12python百行代碼自制電腦端網(wǎng)速懸浮窗的實現(xiàn)
這篇文章主要介紹了python百行代碼自制電腦端網(wǎng)速懸浮窗的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-05-05總結(jié)Python函數(shù)參數(shù)的六種類型
這篇文章主要總結(jié)了Python函數(shù)參數(shù)的六種類型,傳遞參數(shù)實現(xiàn)不同場景的靈活使用,下面總結(jié)的六種函數(shù)參數(shù)類型,需要的小伙伴可以參考一下2022-03-03Python+Matplotlib繪制帶有對角線的散點圖的示例代碼
Matplotlib 是一個用于繪制二維圖形的 Python 庫,這篇文章主要介紹了Python如何利用Matplotlib繪制帶有對角線的散點圖,需要的小伙伴可以參考一下2023-06-06