Python Business card Management

Source: Internet
Author: User

Tags: perform CTI search row modification using hone car function one

Python Business card management is the code that I knock on the video, and subsequent learning will continue to update


ImportCard_tools#infinite loops, determined by the user when to exit whileTrue:#menu for displaying featuresCard_tools.show_menu (); Action_str= Input ("Select the action you want to perform:")    Print("The action you selected is [%s]"%action_str)#the operation of a business card    ifAction_strinch["1","2","3"]:        #New Business Card        ifAction_str = ="1": Card_tools.new_card (); #Show All        elifAction_str = ="2": Card_tools.show_all (); #Query Business Cards        elifAction_str = ="3": Card_tools.search_car (); #Pass    #0 means exiting the system    elifAction_str = ="0":        """if in the development of the program, do not want to immediately compile the branch of the code, you can use the PASS keyword to represent a placeholder, to ensure that the program code correctness program run, the PASS keyword will not do any action"""        Print("Welcome to use the card management system again .")         Break        #Pass    #other content input error, prompt user    Else:        Print("you entered the incorrect, please re-select")

#record all business card informationCard_list = []defShow_menu ():"""Show Menu"""    Print("*"* 50)    Print("Welcome to "business Card management System" V 1.0")    Print("")    Print("1. New Business Card")    Print("2. Show All")    Print("3. Search for Business cards")    Print("")    Print("0. Exit the system")    Print("*"* 50)defNew_card ():"""New Business Card"""    Print("-"* 50)    Print("New Business Card")    #1 prompting the user to enter business card informationName = input ("Please enter your name:") Phone= Input ("Please enter the phone number:") QQ= Input ("Please enter QQ:") Email= Input ("Please enter email:")    #2 Create a business card with the user's input informationCard_dict = {        "name": Name,"Phone": Phone,"QQ": QQ,"Email": Email}#3 Add a business card to the dictionarycard_list.append (card_dict)Print(card_list)#4 Prompt user to add success    Print("added%s's Business card successfully! "%name)defShow_all ():"""Show all Business cards"""    Print("-"* 50)    Print("Show all Business cards")    #determine if there is a card record, if not, prompt the user and return    ifLen (card_list) = =0:Print("There are currently no business card records, please use the new features to talk about the price business card! ")        #The following code will no longer execute        return    #To print a table header     forNameinch["name","Telephone","QQ","Email"]:        Print(Name, end="\t\t")    Print("")    Print("-"* 50)    #Print Split Line    #traverse the list of business cards, output dictionary information sequentially     forCard_dictinchcard_list:Print("%s\t\t%s\t\t%s\t\t%s"% (card_dict["name"], card_dict["Phone"], card_dict["QQ"], card_dict["Email"]))defSearch_car ():"""Search Business Cards"""    Print("-"* 50)    Print("Search Business Cards")    #prompts the user to search for the nameFind_name = input ("Please enter the name you want to search:")    #Traverse business Card list, query the business card to search, if not found, need to prompt the user     forCard_dictinchcard_list:ifcard_dict["name"] ==Find_name:Print("name \t\t phone \t\tqq\t\t Email")            Print("="* 50)            Print("%s\t\t%s\t\t%s\t\t%s"% (card_dict["name"], card_dict["Phone"], card_dict["QQ"], card_dict["Email"]))            #TODO perform modify and delete operations on found business card recordsDeal_card (card_dict) Break    Else:        Print("Sorry,%s not found"%find_name)defDeal_card (find_dict):"""functions for handling business cards"""    Print(find_dict) action_str= Input ("Please select action to perform 1 modify 2 Delete 0 return")    ifAction_str = ="1": find_dict["name"] = Input_card_info (find_dict["name"],"name") find_dict["Phone"] = Input_card_info (find_dict["Phone"],"Tel:") find_dict["QQ"] = Input_card_info (find_dict["QQ"],"QQ:") find_dict["Email"] = Input_card_info (find_dict["Email"],"Email:")        Print("Modify a business card")    elifAction_str = ="2": Card_list.remove (find_dict)Print("Delete a business card")defInput_card_info (dict_value,tip_message):#1. Prompt user inputResult_str=input (tip_message)#2, for user input to judge, if the user entered the content, directly return the results    ifLen (RESULT_STR) >0:returnResult_str#3, if the user does not enter the content, return the original value in the dictionary    Else:        returnDict_value

Python Business card Management

Related Article

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: and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: