print('-'*25)#输出25个横杠
print('-'*25)
print("欢迎使用通讯录")
print("1.添加联系人")
print("2.查看通讯录")
print("3.删除联系人")
print("4.修改联系人")
print("5.查找联系人")
print("6.退出")
print('-'*25)
list1=[0]*10
all_user=[]
while True:
choose= input('请输入你的操作')
#添加联系人操作
if choose == '1':
user={}
name = input('请输入姓名:')
phone = input('请输入手机号:')
email = input('请输入邮箱号:')
address = input('请输入地址:')
if name.strip()==' 'or phone.strip()==' ' or email.strip()==' ' or address.strip()==' ':
print('输入错误')
user['姓名']=name
user['电话']=phone
user['邮箱']=email
user['地址']=address
all_user.append(user)
#查询通讯录
elif choose == '2':
if len(all_user)==0:
print('通讯录为空')
continue
for people in all_user:
for key,values in people.items():
print(key,values,sep=':',end='')
print()
#删除联系人
elif choose == '3':
del_name = input("请输入需要删除的姓名:")
for people in all_user:
if people['姓名'] == del_name:
all_user.remove(people)
break
else:
print('不在通讯录')
#修改联系人
elif choose =='4':
update_name = input("请输入需要修改的姓名:")
for people in all_user:
if people['姓名'] == update_name:
name = input('请输入姓名')
phone = input('请输入手机号')
email = input('请输入邮箱号')
address = input('请输入地址')
people['姓名']=name
print('修改成功')
break
else:
print('不在通讯录')
#查找联系人
elif choose == '5':
search_name = input("请输入需要查找的姓名:")
for people in all_user:
if people['姓名'] == search_name:
for key, values in people.items():
print(key, values, sep=':', end='')
print()
break
else:
print('不在通讯录')
#退出程序
elif choose == '6':
exit('程序已退出')