程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Student address book management system 2.0 of Python basic project practice

編輯:Python

Address book management system 2.0 Mainly to train students to python Function calls and python Application and exit of dead cycle .

python Student address book management system of basic project practice 1.0

python Student address book management system of basic project practice 3.0

Function module analysis

1. home page ( Menu functions )
2. Add users
3. Delete user
4. Modify the user
5. Count the number of contacts in the address book
6. Get all user communication information

7. Exit the system

The code is as follows :

def main():
while True:
menu()
number = int(input(" Please enter the steps of the operation to be implemented :"))
if number==1:
insert() # Add users
if number==2:
delete() # Delete user
if number==3:
modify() # Modify the user
if number==4:
count() # Count the number of contacts in the address book
if number==5:
disply() # Get all user communication information
if number==0:
break
if (number>5 or number<0):
print(" My guest, the input option is wrong , Please re-enter ")
students=[]
def menu():
Menu = """
============================ Student address book management system -2.0=============================
1. Add users
2. Delete user
3. Modify the user
4. Count the number of contacts in the address book
5. Get all user communication information
0. Exit the system
============================================================================
"""
print(Menu)
def insert():
while True:
student={}
student["name"]=input(" The guest officer , Please enter the name of the user to be added :")
student["age"] = input(" The guest officer , Please enter the age of the user to be added :")
student["phone"]=input(" The guest officer , Please enter the phone number of the user to be added :")
student["address"] = input(" The guest officer , Please enter the address of the user to be added :")
students.append(student)
break
def delete():
while True:
name = input(" The guest officer , Please enter the name of the user to be deleted :")
for i in students :
if i["name"]==name:
students.remove(i)
print(" The guest officer , Delete user succeeded !")
print(students)
break
def modify():
while True:
name = input(" The guest officer , Please enter the name of the user to be modified :")
for i in students:
if i["name"]== name:
i["name"]=input(" The guest officer , Please enter the name of the modified user :")
i["age"]=input(" The guest officer , Please enter the age of the modified user :")
i["phone"] = input(" The guest officer , Please enter the phone number of the modified user :")
i["address"] = input(" The guest officer , Please enter the address of the modified user :")
break
def count():
n=len(students)
print(" The address book has ",n," Contacts ")
def disply():
print('='*50)
for student1 in students:
for key,value in student1.items():
print(key,":",value)
print('='*50)
main()

figure :

 

 

 

 

 

 

 

 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved