python3.6 pycharm anaconda3基础名片管理
# 名片管理功能
print('#'*50)
print('名片管理系统V8.1')
print('#'*50)
print('1 添加')
print('2 删除')
print('3 修改')
print('4 查询')
print('5 显示所有的名片')
print('6 退出')
# 用来存储名片
card =[]
while True:
num = int(input('请输入编号:'))
if num == 1:
new_name = input("请输入新的名字:")
new_qq = input("请输入新的qq:")
new_weixin = input("请输入新的微信:")
new_addr = input("请输入新的地址:")
#定义新的字典存储新的名片
new_info ={}
new_info['name'] = new_name
new_info['qq'] = new_qq
new_info['weixin'] = new_weixin
new_info['addr'] = new_addr
card.append(new_info)
print(card)
elif num == 2:
del_name = input('请输入要删除的名字:')
elif num == 3:
pass
elif num == 4:
find_name = input('请输入名字:')
find_flag =0 # 默认没有找到
for temp in card:
if temp['name']==find_name:
print("%s\t%s\t%s\t%s" % (temp['name'], temp['qq'], temp['weixin'], temp['addr']))
find_flag=1
if find_flag == 0:
print('查无此人')
elif num == 5:
print("%s\t%s\t%s\t%s" % ('姓名', 'qq', '微信', '地址'))
for temp in card:
print("%s\t%s\t%s\t%s"%(temp['name'],temp['qq'],temp['weixin'],temp['addr']))
# break
elif num == 6:
break
else:
pass
转载自:https://blog.csdn.net/limingyue0312/article/details/81943604