python语言名片管理系统,进行增删改查

def men():
    print("\t*****************")

    print("\t  名片管理系统\n")

    print("\t  1.添加名片\n")

    print("\t  2.删除名片\n")

    print("\t  3.修改名片\n")

    print("\t  4.查询名片\n")

    print("\t  5.退出系统\n")

    print("\t 0.显示所有名片\n")

    print("\t*****************")

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)


def showList(aList):
    print("名字: %s" % aList[0], \
 \
          "电话:%s" % aList[1], \
 \
          "地址:%s" % aList[2], "\n")


def showMem(aList):
    if len(aList) == 0:
        print("没有联系人!")

    for mumList in aList:
        print("名字: %s" % mumList[0], \
 \
              "电话:%s" % mumList[1], \
 \
              "地址:%s" % mumList[2], "\n")


def delMem(aList):
    i = 0

    if len(aList) == 0:
        print("没有联系人,请先添加联系人!")

        return

    tempName = input("输入要删除的联系人:")

    for mumList in aList:

        if tempName != mumList[0]:

            i += 1

            continue

        else:

            showList(aList[i])

            while True:

                tempIn = input("是否删除此联系人: Y(是)\t N(否) :")

                if tempIn == "Y" or tempIn == "y":

                    del (aList[i])

                    print("删除成功!")

                    return

                elif tempIn == "N" or tempIn == "n":

                    print("重新输入联系人!")

                    delMem(aList)

                    return

                else:

                    print("输入有误,重新输入!")

    if i == len(aList):
        print("输入的联系热不存在,请重新输入!")

        delMem(aList)


def modMem(aList):
    i = 0

    if len(aList) == 0:
        print("没有联系人,请先添加联系人!")

        return

    tempList = input("输入需要修改的联系人:")

    for numList in aList:

        if tempList != numList[0]:

            i += 1

            continue

        else:

            tempInf = input("输入修改的信息:")

            if tempInf.isnumeric():

                numList[1] = tempInf

            else:

                numList[2] = tempInf

    if i == len(aList):
        print("输入有误,重新输入!")

        modMem(aList)


def LocaMem(aList):
    i = 0

    if len(aList) == 0:
        print("没有联系人,请先添加联系人!")

        return

    tempList = input("输入需要查找的联系人:")

    for numList in aList:

        if tempList != numList[0]:

            i += 1

            continue

        else:

            showList(numList)

    if i == len(aList):
        print("输入有误,重新输入!")

        modMem(aList)


if __name__ == "__main__":

    mainList = []

    men()

    while True:

        index = input("输入任务编号:")

        if not index.isnumeric():
            print("请输入索引编号(1-4):")

            continue

        index = int(index)

        # 遍历名片

        if index == 0:
            showMem(mainList)

        # 增加名片

        if index == 1:
            increMem(mainList)

        if index == 2:
            delMem(mainList)

        if index == 3:
            modMem(mainList)

        if index == 4:
            LocaMem(mainList)

        if index == 5:
            print("退出系统!")

            break

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值