Python practiced hand Series--Business card management system

Source: Internet
Author: User

List or dictionary make global variable call in function can not add global

#used to store business cardsCard_infors = []defPrint_menu ():"""Finish the Print function menu"""    Print('='* 50)    Print('Business Card Management system function Edition')    Print('1. Add a new business card')    Print('2. Delete a business card')    Print('3. Modify a business card')    Print('4. Query a business card')    Print('5. Show All business cards')    Print('6. Launch the system')    Print('='* 50)defadd_new_card_infor ():"""complete the Add a new business card"""new_name= Input ('Please enter a new name:') New_qq= Input ('Please enter the new QQ:') New_weixin= Input ('Please enter a NEW:') new_addr= Input ('Please enter a new address:')    #define a new dictionary to store a new business cardNew_infor ={} new_infor['name'] =new_name new_infor['QQ'] =new_qq new_infor['Weixin'] =new_weixin new_infor['Addr'] =new_addr#add a dictionary to the list    Globalcard_infors card_infors.append (new_infor)deffind_card_infor ():"""query a business card"""    Globalcard_infors Find_name= Input ('Please enter the name you want to query:') Find_flag=0 forTempinchcard_infors:ifFind_name = = temp['name']:            Print("%s\t%s\t%s\t%s\t"% (temp['name'], temp['QQ'], temp['Weixin'], temp['Addr'])) Find_flag= 1 Break    ifFind_flag = =0:Print("no such person ....")defshow_all_infor ():"""Show All business card information"""    Globalcard_inforsPrint("name \tqq\t\t address")     forTempinchcard_infors:Print("%s\t%s\t%s\t%s"% (temp['name'], temp['QQ'], temp['Weixin'], temp['Addr']))defMain ():#1. Print function TipsPrint_menu () whileTrue:num= Int (Input ('get the user's input number:'))        ifnum = = 1: Add_new_card_infor ()elifnum = = 2:            Pass        elifnum = = 3:            Pass        elifnum = = 4: Find_card_infor ()elifnum = = 5: Show_all_infor ()elifnum = = 6:             Break        Else:            Print('input Error, please re-enter')        Print(" ")#calling the main functionMain ()

Python practiced hand Series--Business card management system

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: 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.