|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
通讯录的课后作用
print('欢迎进入通讯录查询:')
print('1:查询联系人资料')
print('2:插入联系人资料')
print('3:删除联系人资料')
print('4:退出查询')
def zl():
n = input('输入指令:')
while not n.isdigit() or int(n) > 4:
n = input('输入错误,请输入1-4的整数')
return txl(n)
def txl(n):
n = int(n)
# dict1= dict()
if n == 1:
name = input('输入要查询的姓名:')
print(dict1['name'])
return zl()
elif n == 2:
name = input('输入要添加的姓名:')
tle = input('输入号码:')
dict1[name]=tle
return zl()
elif n == 3:
name = input('输入要删除的姓名:')
if name in dict1:
qr = input('是否确认删除(y/n)')
if qr == 'y':
del dict1[name]
print('删除成功')
elif qr == 'n':
print('取消删除')
else:
print('输入错误,请重新开始执行操作')
return zl()
else:
print('退出通讯录')
return 0
dict1= dict()
zl()
执行的时候添加可以,查询会报错
|
|