def ch(lista):
name1 = input('姓名:')
phone1 = input('電話:')
qq1 = input('QQ:')
emeal1 = input('郵箱:')
if name1 == '':
name1 = lista[0]
if phone1 == '':
phone1 = lista[1]
if qq1 == '':
qq1 = lista[2]
if emeal1 == '':
emeal1 = lista[3]
return name1, phone1, qq1, emeal1
library = [['姓名', 'phone', 'QQ', 'email']]
while True:
print('''
1、新增名片
2、顯示名片
3、查詢名片
0、退出系統
''')
choose = input('請輸入功能序號:')
if '0' < choose <= '3':
if choose == '1':
in_name = input('請輸入姓名:')
in_phone = input('請輸入電話:')
in_qq = input('請輸入qq號:')
in_email = input('請輸入郵箱:')
determine = input('確定新增請輸1,否則請輸其他:')
if determine == '1':
new = [in_name, in_phone, in_qq, in_email]
library.append(new)
else:
continue
if choose == '2':
for a, b, c, d in library:
print(a.ljust(15), b.ljust(15), c.ljust(15), d.ljust(15))
if choose == '3':
key = input('請輸入您要查詢的關鍵字:')
flag=False
for i, element in enumerate(library):
a, b, c, d = element[0], element[1], element[2], element[3]
if a == key or b == key or c == key or d == key:
flag=True
print(a, b, c, d)
print('【1】修改【2】刪除【0】返回')
change = input('請輸入序號:')
if change == '1':
library[i] = ch(element)
elif change == '2':
library.pop(i)
elif change == '0':
break
else:
print('輸入錯誤')
break
if flag:
pass
else:
print('用戶不存在')
elif choose == '0':
break
else:
print('您輸入有誤,請重新輸入序號')
功能:
1、保存信息
2、提取信息
3、修改信息
4、通過名字,電話,qq,或者,email搜索查找
5、退出,返回上級等