#!/usr/bin/python # -*- coding: UTF-8-*- #----author:valecalida---- import sys def display(): print("----------Business Card Management System----------") print("\t\t1.添加一个新的名片") print("\t\t2.删除一个名片") print("\t\t3.修改一个名片") print("\t\t4.查询一个名片") print("\t\t5.显示所有的名片") print("\t\t6.退出系统\n") def insert(): user_name = input("Please enter a name :") QQ_ID = int(input("Please enter the QQ id :")) address = input("Please enter the address :") card = {} card['Name'] = user_name card['QQ'] = QQ_ID card['Address'] = address Card_info.append(card) print("You have insert a piece of info.\n") def delete(): del_all = input("Enter 'All' to clear all info or enter 'Name' to delete info by name.") if del_all == 'All': Card_info.clear() else: del_enter = input("Enter the name you want to clear:") for info in Card_info: if del_enter == info['Name']: Card_info.remove(info) def change(): chan_input = input("Whose info would you like to change?enter the name:") for info in Card_info: if chan_input == info['Name']: new_user_name = input("Please enter a name :") new_qq_id = int(input("Please enter the QQ id :")) new_address = input("Please enter the address :") info['Name'] = new_user_name info['QQ'] = new_qq_id info['Address'] = new_address def find_all(): user_find = input("Please enter the name you want to find: ") for card_info in Card_info: if card_info['Name'] == user_find: show = input("You find the info of " + user_find + ". " + "Do you want to show it?[y]/[n]") new_car = card_info if show == 'y': for key,value in new_car.items(): print (key + ":" + str(value)) break else: pass else: print("There is no person called " + user_find + ".") def show_all(): if Card_info: for info in Card_info: new_car = info for key, value in new_car.items(): print (key + ":" + str(value) + "\n") else: print("There is no info.") user = { 'vale':'123456', 'calida':'123123', 'arnyek':'521000' } Card_info = [] user_input = str(input("Please enter your name: ")) pass_input = str(input("Please enter your password: ")) while user_input in user and pass_input == user.get(user_input): print("Welcome ,master.") user_input_again = input("Whether continue or not? [y]/[n]/[q]") if user_input_again == 'y': while True: display() user_choice = input("请选择您要进行的操作:") if user_choice == '1': insert() elif user_choice == '2': delete() elif user_choice == '3': change() elif user_choice == '4': find_all() elif user_choice == '5': show_all() else: sys.exit() elif user_input_again == 'n': pass else: break else: print("You got a wrong username or password,please try it later.") ##完善后追发