This article mainly introduces the python implementation of the student address book management system in detail for everyone. The sample code in the article is very detailed and has a certain reference value. Interested friends can refer to it. |
The examples in this article share the specific code of python to implement the student address book management system for your reference. The specific content is as follows
Function module analysis:
1. Home page (menu function)
2. Add students
3. Delete students
4. Modify students
5. Count the number of contacts in the address book
6. Get all student communication information
code show as below:
def main(): while True: menu() number = int(input("Please enter the serial number of the operation that needs to be implemented:")) if number==1: insert() #Add student if number==2: delete( ) #Delete students if number==3: modify() #Modify students if number==4: count() #Count the number of contacts in the address book if number==5: disply() #Get all student communication information if number= =0: x=input("Enter yes to exit the system, enter any other characters without exiting:") if x == "yes": break studentlist=[] def menu(): Menu = """ ===== =============== Student Address Book Management System-V1.0==================== 1. Add students 2. Delete students 3. Modify students 4. Count the number of contacts in the address book 5. Get all student communication information 0. Exit the system ================================================== === """ print(Menu) def insert(): while True: studentdict={} studentdict["serial number"]=input("Please enter the serial number of the student to be added:") studentdict["name"]=input ("Please enter the name of the student to be added:") studentdict["Phone"]=input("Please enter the phone number of the student to be added:") studentlist.append(studentdict) x = input("Enter no to end add student, enter Any other characters will continue: ") if x=="no": break def delete(): while True: i=input("Please enter the serial number of the student to be deleted:") for index,item in enumerate(studentlist) : if item["serial number"]==i: del studentlist[index] x = input("Delete students at the end of input no, input other characters will continue:") if x == "no": break def modify(): while True: i = input("Please enter the serial number of the student to be modified:") for item in studentlist: if item["serial number"]==i: item["name"]=input("Please enter the modified student's name :") item["Phone"]=input("Please enter the modified student's phone number:") x = input("Enter no to end the modification of the student, input any other characters will continue:") if x == "no ": break def count(): a=len(studentlist) print("Total address book",a,"contact person") def disply(): print('------------ ---------------') for studentdict_1 in studentlist: for key,value in studentdict_1.items(): print(key,":",value) print('---- -----------------------') main()
The above is the whole content of this article, I hope it will be helpful to everyone's study.