zoukankan      html  css  js  c++  java
  • Python(用for,if)实现简单的名片管理系统

    想要py文件的可以留言给我,也可以一起交流。
    这个脚本是在ubuntu中用vim写的,所以有些注释打成拼音去了。
    欢迎指出不足之处!
     
     
    #1.打印功能ti'sh 
    print("+"*50)
    print("名片管理系统 V0.0.1")
    print("1:添加名片信息")
    print("2:删除名片信息")
    print("3:修改名片信息")
    print("4:查询名片信息")
    print("5:显示所有名片信息")
    print("6:退出系统")
    print("+"*50)

    # 用来存储名片
    card_infos = []

    # 获取用户shu'ru 信息
    while True:
        num = int(input("qing 输入功能序号:"))

        # 根据用户的shuj zhixing xiangyin de gongneng 
        if num== 1:
            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

            #把字典数据存放在列表里面
            card_infos.append(new_info)
            
            #print(card_infos)


        elif num==2:
            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("此人还没登记过不能删除")

        elif num==3:
            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
                
            
        elif num==4:
            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("没有找到此人!")
                '''


                

        elif num==5:
            print("姓名 QQ 微信 地址")
            print("-+-+"*20)
            for temp in card_infos:
                print("%s %s %s %s"%(temp['name'],temp['qq'],temp['weixin'],temp['addr']))
            print("-+-+"*20)
        elif num==6:
            break
        else:
            print("输入有误请chongg'xin shuru")
        pass
        print("="*20)
  • 相关阅读:
    Div+CSS+JQuery实现选项卡,即通过点击不同的li跳转到不同的div中显示不同的内容或者执行不同的操作。
    js如何获取点击<li>标签里的内容值
    python requests库爬取网页小实例:ip地址查询
    python requests库爬取网页小实例:爬取网页图片
    python requests库网页爬取小实例:百度/360搜索关键词提交
    python requests库网页爬取小实例:亚马逊商品页面的爬取
    python使用requests库爬取网页的小实例:爬取京东网页
    hibernate 的入门
    html
    事务的入门(mysql)
  • 原文地址:https://www.cnblogs.com/pooopun/p/12535069.html
Copyright © 2011-2022 走看看