#!/usr/bin/python # -*- coding: UTF-8-*- #----author:valecalida---- #主要以列表的功能实现,欢迎大家测试,提出您宝贵的意见 import sys def menu(): print("----------Business Card Management System----------") print("\t\t\t1.添加一个新的名片") print("\t\t\t2.删除一个名片") print("\t\t\t3.修改一个名片") print("\t\t\t4.查询一个名片") print("\t\t\t5.显示所有的名片") print("\t\t\t6.退出系统\n") def add(): print("请输入要添加的信息:") card_info = [] name = input("\t\t请输入姓名:") qq_id = input("\t\t请输入QQ ID:") tel = input("\t\t请输入Telphone number:") card_info.append(name) card_info.append(qq_id) card_info.append(tel) Card_infos.append(card_info) print("正在新建,请稍后......") print("Done\n") Card_infos = [] def change(): if Card_infos: change_input = input("请输入您要修改人的名字:") for info in Card_infos: if change_input == info[0]: name = input("请输入姓名:") qq_id = input("请输入QQ ID:") tel = input("请输入Tel number:") info[0] = name info[1] = qq_id info[2] = tel print("正在修改,请稍后......\nDone\n") else: print("系统中没有人叫:" + info['name']) else: print("系统里没有任何信息,无法进行修改\n") def clear(): clear_choice = input("Enter 'a' to clear all;Enter 'n' to clear by name:") if clear_choice == 'a': Card_infos.clear() elif clear_choice == 'n': del_name = input("请输入您要删除人的名字:") for info in Card_infos: if del_name == info[0]: Card_infos.remove(info) print("正在删除,请稍后....\nDone.\n") else: print("请确定您的输入符合输入标准\n") def search(): if Card_infos: search_choice = input("请输入你要查找人的名字:") for info in Card_infos: if search_choice == info[0]: print("\tName:" + info[0] + "\n\tQQ:" + info[1] + "\n\tTel num:" + info[2] + "\n") else: print("系统中没有人叫:" + search_choice + "\n") else: print("系统里没有任何信息,无法进行查询\n") def display_all(): if Card_infos: for infos in Card_infos: print("\tName:" + infos[0] + "\n\tQQ:" + infos[1] + "\n\tTel num:" + infos[2] + "\n") else: print("系统里没有任何信息.\n") def turn_off(): sys.exit() user = {'vale':'111'} def guest(): user_name = input("请输入您的名字:") user_pass = input("请输入您的密码:") if user_name in user_name and user_pass == user.get(user_name): print("welcome to Business Card Management System:") menu() else: print("请确认您的账号密码是否正确,请稍后再试。") exit() def run_system(): guest() while True: run_id = input("请输入要进行的操作,按q退出:") if run_id == '1': add() elif run_id == '2': clear() elif run_id == '3': change() elif run_id == '4': search() elif run_id == '5': display_all() elif run_id == '6' or run_id == 'q': turn_off() else: print("请确定您的输入符合输入标准\n") run_system()