前言
之前看过一遍的python教程,真的是自己看过一遍,python的程序能看懂,但是很难去实现。比较困难的自己实现一些代码,找工作原因,自己又认认真真的看书,敲代码,后来看到了这个题目,想把之前学习的python常用的数据类型复习下。花了一点儿时间,编程实现了。
python实现名片管理系统
能实现如下功能:
*****************
名片管理系统
1.添加名片
2.删除名片
3.修改名片
4.查询名片
5.退出系统
0.显示所有名片
*****************
添加名片
编程思路 先创建一个临时的 templist 变量,通过 templist.append()方法,增加,姓名,手机号,地址等信息,然后把templist列表追加到 mainList列表中。
def increMem(aList):
tempList = []
tempName = input("输入新建名片名字:")
tempList.append(tempName)
while True:
tempPhone = input("输入新建联系人手机号:")
if tempPhone.isnumeric(): break
else: print("输入有误,重新输入")
tempList.append(tempPhone)
tempAddr = input("输入新建联系人地址:")
tempList.append(tempAddr)
print("输入新建联系人信息:")
showList(tempList)
aList.append(tempList)
注意:
手机号都是数字,可以通过 list.isnumeric()方法判断是否是纯数字字符串,不是返回False
删除名片
编程思想:首先盘算是否是空,如果是空返回,然后先定位删除联系人的索引值,最后通过del()函数删除联系人。
def delMem(aList):
i = 0
if len(aList) == 0 :
print("没有联系人,请先添加联系人!")
return
tempName = input("输入要删除的联系人:")
for mumList in aList:
if tempN