Python Business card management system V2

Source: Internet
Author: User

To improve the business card management system:

Main program:

#!/usr/bin/env python#-*-coding:utf-8-*-#Item Three:#1, requirements: Write a business card management system, the functions are as follows:#user input of the corresponding instructions, to achieve the business card to increase, delete, change, check the function#2. Analysis#The first is to define a python file, a python file that operates on the program (the entry program), a Python file as a tool, and then add the following features#(1) Increase:#in order to increase the function of a function, when the user input instructions to increase, provide user input information, such as: Name, age, work number, wages, etc., save the user input information. #when more than one user input information, the information entered in a dictionary to save each user's details, and then use the list to save each user's information#(2) Check:#make a function of the view function, and when the user enters the view function, displays the details of all the users individually. #(3) Modification and deletion:#first, a function of the function of the search, the user only need to enter the person name, work number, if it exists in the dictionary, then the search to show all the details of the people,#(3.1) Add delete function, user input Delete command, delete all the information of the person searched#(3.2) Add the modification function, after the user enters the modification instruction, changes the detailed information of the person who is searched .#3. Code#Entry ProceduresImportItem03_cards_toolsPrint("*"* 50)Print("Welcome to the card management system")Print("*"* 50) whileTrue:Print("This system function: "1" added business Card "2" View all Business card information "3" Search business Card [0] Exit") User= Input ("Please select your features:")    #the operation of a business card    ifUserinch["1","2","3"]:        #New Business Card        ifuser = ="1": Item03_cards_tools.card_add ()Print(item03_cards_tools.cards_list)#Show All        elifuser = ="2": Item03_cards_tools.show_all ()#Search Business Cards        elifuser = ="3": Item03_cards_tools.card_serach ()elifuser = ="0":        Print("Welcome to use the card management system again .")         Break    Else:        Print("Illegal input")

Function Program:

#!/usr/bin/env python#-*-coding:utf-8-*-#record all the business card dictionariesCards_list = []defCard_add ():"""New Business Card"""    Print("New Business Card") user_name= Input ("Please enter your name:") User_phone= Input ("Please enter your phone number:") User_qq= Input ("Please enter your QQ:") User_email= Input ("Please enter your e-mail:")    #user-entered information is created to add to the business card dictionaryCards_dict = {        "name": User_name,"Phone": User_phone,"QQ": User_qq,"Email": User_email}#Add a business card dictionary to the listcards_list.append (cards_dict)Print("Add Success")defShow_all ():"""Show all Business cards"""    Print("-"* 50)    Print("View all Business cards")    #determine if a business card record exists    ifLen (cards_list) >0:#To print a table header         forHeaderinch["name","Telephone","QQ","Email"]:            Print(header,end="\t\t")        Print("")        Print("="* 50)        #Traverse business Card list output dictionary information sequentially         forCard_dictinchcards_list:Print("%s\t\t%s\t\t%s\t\t%s"%(card_dict["name"], card_dict["Phone"], card_dict["QQ"], card_dict["Email"]            ))    Else:        Print("you have not added a business card, press "1" to add a business card")defCard_serach ():"""Search Business Cards: return:"""    Print("Search Business Cards")    Print("-"* 50) User_find= Input ("Please enter the information you want to find (if you want to return to the main menu, press "0"):")    ifUser_find = ="0":        return    #traverse the list of business cards, query the name to search for, phone, qq,email, if not found, to prompt the user     forCard_dictinchcards_list:if(card_dict["name"] = = User_findorcard_dict["Phone"] = = User_findorcard_dict["QQ"] = = User_findorcard_dict["Eamil"] ==user_find):Print("found the")            Print(card_dict)#perform modifications and deletions on found business card informationDeal_card (card_dict) Break    Else:        Print("not found")defDeal_card (find_dict):"""process the found business card:p Aram Find_dict: Find a business card"""User_input_info= Input ("Please select function: "1" Modify "2" Delete")    ifUser_input_info = ="1": find_dict["name"] = Input_info_card ("name","Name:") find_dict["Phone"] = Input_info_card ("Phone","Tel:") find_dict["QQ"] = Input_info_card ("QQ","QQ:") find_dict["Email"] = Input_info_card ("Email","Email:")        Print("Modify business Card success! ")    elifUser_input_info = ="2": Cards_list.remove (find_dict)Print("Delete succeeded")    Else:        Print("Illegal input")defInput_info_card (dict_value,prompt):"""Enter business card information:p Aram Dict_value: The value of the dictionary:p Aram prompt: Input prompt: Return: If the user enters the content, returns the content, otherwise returns the value in the dictionary"""User_change_info=input (Prompt)ifUser_change_info! =0:returnUser_change_infoElse:        Print("you have entered an empty")        returnDict_value

Python Business card management system V2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.