Python Small white Road (attribute Syntax III apply business Card Manager project)

Source: Internet
Author: User

#encoding =utf-8print ("Welcome to Pyhon Business Card System") #定义列表存储名片信息list_card = [{' Number ': 1, ' name ': ' Zhanshi ', ' phone ': ' 110 '},{' number ': 2, ' name ': ' Warrior ', ' phone ': ' 119 '}]while true:print ("*" *20) #名片系统功能 print ("Add Business Card" 1 ") print (" Delete business Card "2") print ("Modify Business Card" 3 ") Print (" Query business Card "4") Print ("Query all" 5 ") print (" Destroy system "6") Print ("Exit system" 7 ") Print (" * "*20) str1 = input (" Please enter the function selected: ") if str1 = = ' 1 ': id = int (input ( "Please enter a new number:") name = Input ("Enter new name:") Telphone = input ("Please enter new phone:") #定义字典 Dict_card = {} dict_card[' number '] = ID dict_card[' name '] = name dict_card[' phone '] = telphone #将字典数据插入到列表中 list_card.append (dict_card) print ("Add complete") elif str1 = = ' 2 ': name = input ("please Enter deleted name: ") flag = False for dict_list in list_card:if dict_list[' name '] = = Name:flag = True list_card.remove (dict_list) #b Reak if Flag:print ("Name:%s deleted"%name) Else:print ("%s name not found, cannot delete"%name) continue #删除后功能继续 elif str1 = ' 3 ': name = input ("please Enter the name before the change: ") #默认不存在标志 flag = False for dict_list in list_card:if dict_list[' name '] = = name:new_id = Int (Input (" Enter new number: ")) n Ew_name = input ("Please enter a new name:") new_telphone= Input ("Please enter new phone:") dict_list[' number ') = new_id dict_list[' name '] = new_name dict_list[' phone '] = new_telphone flag = True If flag: Print ("Name:%s modified OK"%name) else:print ("%s name not found, cannot modify"%name) continue elif str1 = ' 4 ': name = input ("Please enter name of query:") #默认不存在标志 Flag = False Print ("=" *20) for dict_list in List_card:if dict_list[' name '] = = name:flag= True if Flag:print ("Number:%d, Name:%s, Phone:%s "% (dict_list[' number '],dict_list[' name '],dict_list[' phone ')) Else:print ("%s not Found "%name) print (" = "*20) Continue Elif str1 = = ' 5 ': print ("=" *20) for Dict in List_card:for Key,value in Dict.items (): Print ("%3s:%s"% (key,value)) print ("=" *20) elif str1 = = ' 6 ': Del list_card print (' Business card system destruction!!! ') Break elif str1 = = ' 7 ': Break Else:print ("Please use business card system as prompted")

Python small white Road (attribute Syntax III apply business Card Manager project)

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.