Python名片管理系統

來源:互聯網
上載者:User

標籤:查詢   python   remove   bug   退出   list   inpu   else   family   

Python名片管理系統

找了很久的 bug,最後發現是 input 沒轉換類型……

 

 1 #!/usr/bin/env python3 2 # -*- coding: utf-8 -*- 3  4 print(**50) 5 print(名片管理系統) 6 print(**50) 7 print(‘‘‘1. 建立名片 8 2. 刪除名片 9 3. 修改名片10 4. 查詢名片11 5. 顯示所有名片12 6. 退出管理系統13 ‘‘‘)14 List = []15 while True:16     choice = int(input(請選擇你的操作:))#記住要轉換類型!17     if choice == 1:18         new_name = input(輸入姓名:)19         new_sex = input(輸入性別:)20         new_age = input(輸入年齡:)21         new_QQ = input(輸入QQ號:)22         card = {}23         card[name] =new_name24         card[sex] = new_sex25         card[age] = new_age26         card[QQ] = new_QQ27         List.append(card)28         print(List)29         30     elif choice == 2:31         fname = input(輸入你要刪除名片的姓名:)32         fflag = 0#沒找到33         for temp in List:34             if temp[name] == fname:35                 List.remove(temp)#此處宜用remove36                 print(List)37                 fflag = 1#找到了38                 break39         if fflag == 0:40             print(沒有這張名片!)41         42     elif choice == 3:43         mname = input(輸入要修改資訊的名片的姓名:)44         flag = 045         i = 046         for temp in List:47             if mname == temp[name]:48                 flag = 149                 print(%s\t%s\t%s\t%s%(temp[name], temp[sex], temp[age], temp[QQ]))50                 mchoice = int(input(選擇要修改的資訊:1. 姓名 2. 性別 3. 年齡 4. QQ 5. 退出 :))#記住轉換類型!!!51                 while True:52                     if mchoice == 1:53                         temp[name] = input(輸入修改后姓名:)54                         flag = 155                     elif mchoice == 2:56                         temp[sex] = input(輸入修改後性別:)57                     elif mchoice == 3:58                         temp[age] = input(輸入修改後年齡:)59                     elif mchoice == 4:60                         temp[QQ] = input(輸入修改後QQ:)61                     elif mchoice == 5:62                         break63                     else:64                         print(輸入錯誤!)65                     print(姓名\t性別\t年齡\tQQ)66                     print(%s\t%s\t%s\t%s%(temp[name], temp[sex], temp[age], temp[QQ]))67                     break68         if flag == 0:69             print(無此名片!)70         71     elif choice == 4:72         fname = input(輸入你要查詢的名片中的姓名:)73         fflag = 0#沒找到74         for temp in List:75             if temp[name] == fname:76                 print(姓名\t性別\t年齡\tQQ)77                 print(%s\t%s\t%s\t%s%(temp[name], temp[sex], temp[age], temp[QQ]))78                 fflag = 1#找到了79                 break80         if fflag == 0:81             print(沒有這張名片!)82     elif choice == 5:83         print(姓名\t性別\t年齡\tQQ)84         for temp in List:85             print(%s\t%s\t%s\t%s%(temp[name], temp[sex], temp[age], temp[QQ]))86     elif choice == 6:87         break88     else:89         print(操作錯誤!請重新選擇!)

 

Python名片管理系統

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.