个人信息卡小程序(Python)

功能:增加个人信息,:查询个人信息,
主程序是product_main.py
调用模块product_info.py

#  以下是主程序product_main.py代码
#  Author:Bruce
#  Vesion:1.0
#  Discription: Business card management system
#  Last modified data: 2010.1.31

while True:
    # Display menu and option
    import product_info
    product_info.show_menu()
    action_str = input("please select the option:")
    print("your selection is [%s]" %action_str)
    # Call the specific function base on user's input
    if action_str in ["1","2","3"]:
        # Create new card
        if action_str == "1":
            product_info.create_card()
        # Display all card
        elif action_str == "2":
            product_info.show_allcards()
        # Search card
        else:
            product_info.search_card()

    # 0 (quit)
    elif action_str == "0":
        print("welcome to use the business card management system")
        break
    # Prompt message
    else:
        print("your input is wrong,please input the correct number")
# 以下是调用模块文件product_info代码
card_list = []


def show_menu():
    print("*" * 50)
    print("Welcome use business card management system V1.0")
    print("")
    print("1.Create new card")
    print("2.Display all card's information")
    print("3.Inquiry specific card")
    print("")
    print("0.Leave")
    print("*" * 50)


def create_card():
    # Define a empty list to record the input card information

    print("*" * 50)
    print("Create new card:")
    # Define 4 strings to store the input
    name_str = input("Please input your name:")
    phone_str = input("Please input your phone number:")
    wechat_str = input("Please input your Wechat number:")
    email_str = input("Please input your E-mail address:")
    card_dict = {"Name": name_str,
                 "Phone": phone_str,
                 "Wechat": wechat_str,
                 "E-mail": email_str}
    # Add the input dictionary to the list (it's empty at first time)
    card_list.append(card_dict)
    # Show cards info and prompt message
    print(card_list)
    print("added %s's card success" % name_str)


def show_allcards():
    print("*" * 50)
    print("All cards' information:")
    if len(card_list) == 0:
        print("There is no record,please create new record")
        return
    # Print key list
    for name in ["Name","Phone","Wechat","E-mail"]:
        print(name, end="\t\t")
    print("")
    # Print split line
    print("=" * 50)
    for card_dict in card_list:
        print("%s\t\t%s\t\t%s\t\t%s" %(card_dict["Name"],card_dict["Phone"],card_dict["Wechat"],card_dict["E-mail"]))


def search_card():
    print("*" * 50)
    user_name = input("Please input user's name:")
    for card_dict in card_list:
        if card_dict["Name"] == user_name:
            for name in ["Name", "Phone", "Wechat", "E-mail"]:
                print(name, end="\t\t")
            print("")
            print("=" * 50)
            print("%s\t\t%s\t\t%s\t\t%s" % (
            card_dict["Name"], card_dict["Phone"], card_dict["Wechat"], card_dict["E-mail"]))

            break
    else:
        print("The name you are searching does not exist")




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值