• 名片管理系统V0.0.2(函数实现)


    这张图片是写python脚本大体的顺序,接下来展示代码。

    版本 V0.0.2,python 3.7.3 操作系统ubuntu
     
    # 版本 V0.0.2
    # 存储信息的列表
    card_infos = []

    # 打印菜单函数
    def print_menu():
        """完成打印菜单功能"""
        print("="*30)
        print("名片管理系统 V0.0.2")
        print("   1.添加名片")
        print("   2.删除名片")
        print("   4.查询名片")
        print("   5.显示所有名片")
        print("   6.退出系统")
        print("="*30)

    def add_new_card_info():
        """完成添加名片"""
        new_name = input("请输入名字:")
        new_qq = input("请输入输入QQ:")
        new_weixin = input("请输入新的微信:")
        new_addr = input("请输入新的地址:")
        # 定义新的字典,用来存储yi'ge 新的名片
        new_info = {}
        new_info['name'] = new_name
        new_info['qq'] = new_qq
        new_info['weixin'] = new_weixin
        new_info['addr'] = new_addr
        #把字典数据存放在列表里面
        global card_infos
        card_infos.append(new_info)
        #print(card_infos)

    # 删除功能
    def del_card():
        global card_infos
        del_name = input("请输入要删除的名字:")
        find_flag = 0 #默认表示没有删除
        for temp in card_infos:
            if del_name == temp["name"]:
                print("你将要修改一下信息 ")
                print("-+-+"*20)
                print("姓名 QQ 微信 地址")
                print("%s %s %s %s"%(temp['name'],temp['qq'],temp['weixin'],temp['addr']))
                y = int(input("确认修改这条信息吗? 1:删除 0:取消 "))
                if y==1:
                    card_infos.remove(temp)
                else:
                    print("已经取消删除该信息!")
                find_flag +=1 #1表示找到了
                break
        if find_flag == 0:
            print("此人还没登记过不能删除")


    # 修改功能
    def update_card():
        """完成修改功能"""
        global card_infos
        del_name = input("请输入要修改的名字:")
        for temp in card_infos:
            if del_name == temp["name"]:
                print("你将修改这条信息")
                print("-+-+"*20)
                print("姓名 QQ 微信 地址")
                print("%s %s %s %s"%(temp['name'],temp['qq'],temp['weixin'],temp['addr']))
                info = ["名字","QQ","微信","地址"]
                name1 = input("请输入新的%s "%info[0])
                qq1 = input("请输入新的%s "%info[1])
                weixin1 = input("请输入新的%s "%info[2])
                addr1 = input("请输入新的%s "%info[3])
                temp['name'] = name1
                temp['qq'] = qq1
                temp['weixin'] = weixin1
                temp['addr'] = addr1
                print("这条信息变更为:")
                if name1 == temp["name"]:
                    print("%s %s %s %s"%(temp['name'],temp['qq'],temp['weixin'],temp['addr']))
                else:
                    print("此条信息异常!")
                break


    # 查找功能
    def find_card_info():
        """完成查找功能"""
        global card_infos
        find_name = input("请输入yao查找的姓名")
        find_flag = 0 #默认表示没找到
        for temp in card_infos:
            if find_name == temp["name"]:
                print("-+-+"*20)
                print("姓名 QQ 微信 地址")
                print("%s %s %s %s"%(temp['name'],temp['qq'],temp['weixin'],temp['addr']))
                find_flag +=1 #1表示找到了
                break
        if find_flag == 0:
            print("查无此人")
            # 50 行到64行可以用下面代码替代
            '''
            find_name = input("请输入要查找的名字")
            for temp in card_infos:
                if temp['name'] == find_name:
                    print("找到了")
                    break
            else:
                print("没有找到此人!")
            '''

    # 显示名片函数
    def display_card():
        print("姓名 QQ 微信 地址")
        print("-+"*20)
        for temp in card_infos:
            print("%s %s %s %s"%(temp['name'],temp['qq'],temp['weixin'],temp['addr']))
        print("-+"*20)




    def main():
        """程序主函数。控制整个程序"""
        # 调用打印菜单函数
        print_menu()
        while True:
            num = int(input("请输入操作序号:"))
            if num==1:
                add_new_card_info()
            elif num==2:
                del_card()
            elif num==3:
                update_card()
            elif num==4:
                find_card_info()
            elif num==5:
                display_card()
            elif num==6:
                break

    # 调用主函数
    main()
     
  • 相关阅读:
    时间序列理论专题之二 时间序列的表达
    Ado.net Entity FrameWork的性能问题
    时间序列专题之三 时间序列的分段线性表示
    Tfs 2010使用小技巧
    时间序列理论专题之一 前言
    绝大多数新技术的学习,都是浪费生命
    Tfs2010简体中文版:翻译永远是问题
    MSsql 查询时默认是不区分大小写。 可以用语句强制sql语句查询时区分大小写 狼
    将.NET dll注册到GAC(Global Assembly Cache)中 狼
    js重载 狼
  • 原文地址:https://www.cnblogs.com/pooopun/p/12556044.html
Copyright © 2020-2023  润新知