1 list=[] 2 while True: 3 print('*'*10 ,'欢迎来到名片管理系统','*'*10) 4 print(' 1.查询名片') 5 print(' 2.添加名片') 6 print(' 3.删除名片') 7 print(' 4.修改名片') 8 print(' 5.退出系统') 9 print('#'*42) 10 choose = input('请输入您要选择的序号:').strip() 11 if choose =='1': 12 if list: 13 i=0 14 length=len(list) 15 while i<length: 16 print('%s.姓名:%s |职务:%s |电话:%s' % (i+1,list[i]['name'],list[i]['job'],list[i]['phone'])) 17 i+=1 18 else: 19 print('名片为空') 20 elif choose =='2': 21 name=input('姓名:').strip() 22 job=input('职务:').strip() 23 phone=input('电话: ').strip() 24 if name and job and phone: 25 list.append({ 26 'name':name, 27 'job':job, 28 'phone':phone 29 }) 30 else: 31 print('请输入内容,不然砍死你!') 32 elif choose =='3': 33 j=0 34 while j<len(list): 35 print('%s.姓名:%s |职务:%s |电话:%s' % (j+1,list[j]['name'],list[j]['job'],list[j]['phone'])) 36 j += 1 37 delet=input('请输入删除序号:').strip() 38 list.remove(list[int(delet)-1]) 39 print('该名片已删除') 40 elif choose =='4': 41 k=0 42 while k< len(list): 43 print('%s.姓名:%s |职务:%s |电话:%s' % (k+1,list[k]['name'],list[k]['job'],list[k]['phone'])) 44 k += 1 45 res=input('请输入你要修改的内容:') 46 modify1=input('姓名:') 47 modify2=input('职务:') 48 modify3=input('电话: ') 49 if modify1: 50 list[int(res)-1]['name']=modify1 51 list[int(res)-1]['job']=modify2 52 list[int(res)-1]['phone']=modify3 53 print('修改完成') 54 else: 55 print('请正确输入') 56 57 elif choose=='5': 58 print('您已退出') 59 break 60 else: 61 print('请输入1,2,3,4,')