Python Business card management system
After a long time to find the bug, and finally found that the input did not convert the type ...
1 #!/usr/bin/env Python32 #-*-coding:utf-8-*-3 4 Print('*'*50)5 Print('Business Card Management system')6 Print('*'*50)7 Print(" "1. Create a new business card8 2. Delete a business card9 3. Modify the business cardTen 4. Inquire about business cards One 5. Show All business cards A 6. Exit the management system - " ") -List = [] the whileTrue: -Choice = Int (input ('Please select your action:'))#Remember to convert the type! - ifChoice = = 1: -New_name = input ('Enter your name:') +New_sex = input ('Enter Gender:') -New_age = input ('Enter Age:') +NEW_QQ = input ('Enter QQ number:') ACard = {} atcard['name'] =new_name -card['Sex'] =New_sex -card[' Age'] =New_age -card['QQ'] =NEW_QQ - list.append (Card) - Print(List) in - elifChoice = = 2: tofname = input ('Enter the name of the business card you want to delete:') +Fflag = 0#didn't find - forTempinchList: the iftemp['name'] ==fname: *List.remove (temp)#It is advisable to use the Remove $ Print(List)Panax NotoginsengFflag = 1#found the - Break the ifFflag = =0: + Print('There's no business card! ') A the elifChoice = = 3: +Mname = input ('Enter the name of the business card for which you want to modify information:') -Flag =0 $i =0 $ forTempinchList: - ifMname = = temp['name']: -Flag = 1 the Print('%s\t%s\t%s\t%s'% (temp['name'], temp['Sex'], temp[' Age'], temp['QQ'])) -mchoice = Int (input ('Select the information you want to modify: 1. Name 2. Gender 3. Age 4. QQ 5. Exit:'))#remember the conversion type!!! Wuyi whileTrue: the ifMchoice = = 1: -temp['name'] = input ('Enter modified name:') WuFlag = 1 - elifMchoice = = 2: Abouttemp['Sex'] = input ('Enter modified gender:') $ elifMchoice = = 3: -temp[' Age'] = input ('Enter the modified age:') - elifMchoice = = 4: -temp['QQ'] = input ('Enter the modified QQ:') A elifMchoice = = 5: + Break the Else: - Print('input Error! ') $ Print('name \ t sex \ t age \tqq') the Print('%s\t%s\t%s\t%s'% (temp['name'], temp['Sex'], temp[' Age'], temp['QQ'])) the Break the ifFlag = =0: the Print('no such business card! ') - in elifChoice = = 4: thefname = input ('Enter the name of the business card you want to query:') theFflag = 0#didn't find About forTempinchList: the iftemp['name'] ==fname: the Print('name \ t sex \ t age \tqq') the Print('%s\t%s\t%s\t%s'% (temp['name'], temp['Sex'], temp[' Age'], temp['QQ'])) +Fflag = 1#found the - Break the ifFflag = =0:Bayi Print('There's no business card! ') the elifChoice = = 5: the Print('name \ t sex \ t age \tqq') - forTempinchList: - Print('%s\t%s\t%s\t%s'% (temp['name'], temp['Sex'], temp[' Age'], temp['QQ'])) the elifChoice = = 6: the Break the Else: the Print('Operation Error! Please re-choose! ')
Python Business card management system