先写一个名片管理系统简单版,后续改进
#!/usr/bin/env python3
# -*- conding:utf-8 -*-
# @Time: 2017/12/15 12:27
# @Author:Luke
# 名片系统。。持续开发中。。。还有函数,模块等=没加进来,预先演练
cardSys = [{"name":"张三","telephone":"15892233331","QQ":"12345","email":"12345@qq.com"},
{"name":"刘美","telephone":"15892244441","QQ":"23456","email":"23456@qq.com"},
{"name":"李四","telephone":"15892255551","QQ":"34567","email":"34567@qq.com"},
{"name":"王五","telephone":"15892266661","QQ":"45678","email":"45678@qq.com"}]
digit = -1
while digit!=0:
print("*" * 30)
print("欢迎使用【名片管理系统】v1.0".center(10))
print("1.新建名片".center(10))
print("2.显示全部".center(10))
print("3.查询名片".center(10))
print("0.退出系统".center(10))
print("*" * 30)
digit = input("请选择操作的功能:")
if digit != 0 or digit != 1 or digit != 2 or digit != 3:
print("您输入的有误!")
break
elif int(digit) == 1:
print("新建名片中。。。")
name = input("请输入姓名:")
telephone = input("请输入电话:")
QQ = input("请输入QQ:")
email = input("请输入电子邮箱:")
cardSys.append({"name":name,"telephone":telephone,"QQ":QQ,"email":email})
print(cardSys)
elif int(digit) == 2:
print("显示所有名片:")
print("姓名 电话 QQ 邮箱")
for k in cardSys:
for name in k:
print("%s"% k[name],end=" ")
print("")
elif int(digit) ==3:
print("查询名片。。。")
findName = input("请输入姓名:")
for xm in cardSys:
if findName in xm["name"]:
print("找到了%s,名片如下:"%findName)
print(xm)
break
else:
print("没有找到 %s" % findName)
elif int(digit) ==0:
break