code

Student = list() def showMenu(): print("1 ") ") print("2. Delete ") print("3. Print ("0 ") print("0 ") ") select eval(input(" input: ") return def addStudent(): Print (" -- -- -- -- -- to increase student information -- -- -- -- -- ") name = input (" name: ") sex = input (" gender: ") age = input (" age: ") phone = input (" call: ") Student. Append ({" name ": name," sex ": sex," age ": the age," phone ": phone}) print (" add success!" Def showStudent(): if len(student) == 0: print(" if len(student) == 0 ") ) the else: print (" -- -- -- -- -- -- -- -- -- -- - student information -- -- -- -- -- -- -- -- -- -- -- -- ") print (" serial number \ \ t t name gender age \ \ t t call ") for I in range (0, len (student) : print("%d\t%s\t%s\t%s\t%s"%(i+1,student[i].get('name'),student[i].get('sex'),student[i].get('age'),student[i].get('phone '))) print (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ") # delete student information def delStudent () : Print (" -- -- -- the ongoing delete -- - ") print (" -- -- -- -- - the current student information -- -- -- -- -- - ") showStudent = eval () the select (input (" please enter to delete student number: ")) del Student [select-1] print() Def reviseStudent(): studict = {1: "name", 2: "sex", 3: "age", 4: "Phone"} print (" -- -- -- -- -- are modified operation -- -- -- -- -- ") showStudent num = eval (), input (" please input to modify student number: ")) Print ("1- change name \n2- Change gender \ N3 - Change age \ N4 - Change phone number ") Revisenum = eval(input(" Please enter new information :") newstr = input(" Please enter new information :") Student [num-1][studict[Revisenum]] = print( Select * from showStudent() if select == 1: select * from showStudent() if select == 1: addStudent() elif select == 2: delStudent() elif select == 3: reviseStudent() elif select == 4: ShowStudent () elif select == 0: Please try again!" ) continue init()Copy the code

The results

  1. PS: If you need Python learning materials, please click the link below to get them

Free Python learning materials and group communication solutions click to join

2. Delete student information

! [](https://p1.pstatp.com/origin/pgc-image/20ed67f7a6ee4aec8ebcdacc193017e1)

3. Modify student information

! [](https://p1.pstatp.com/origin/pgc-image/2988e34610fc46ca8269020e1f671687)

4. Display student information

! [](https://p1.pstatp.com/origin/pgc-image/ec2128d117094b6e9f4025e4378b81b1)