国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > Python > 正文

名片管理系統(tǒng)python版

2020-02-16 11:34:31
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

本文實(shí)例為大家分享了python名片管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

import oslist_all = []def page(): """輸出主頁(yè)面""" print("*" * 30) print("歡迎使用[名片管理系統(tǒng)]v2.0") print() print("1.新建名片") print("2.查看全部") print("3.查詢名片") print("4.保存信息") print() print("0.退出系統(tǒng)") print("=" * 30)def new_cards(): """接收用戶輸入的信息保存至字典""" dict_1 = {"name": input("姓名:"),    "age": input("年齡:"),    "phone": input("電話:"),    "email": input("郵箱:")} # 將字典添加至列表 list_all.append(dict_1)def check_all(): """將所有的字典信息進(jìn)行打印""" if len(list_all) > 0:  print("姓名/t/t年齡/t/t電話/t/t郵箱")  for i in list_all:   print("%s/t/t%s/t/t%s/t/t%s" % (i["name"], i["age"],           i["phone"], i["email"])) else:   print("還沒(méi)有任何信息")def check_cards(): """查詢名片""" user = input("請(qǐng)輸入要查詢的姓名:") for i in list_all: # 遍歷全局列表,將存入的字典依次取出  if i['name'] == user: # 如果字典的值跟用戶搜索的值相同打印字典   print("姓名/t/t年齡/t/t電話/t/t郵箱")   print("%s/t/t%s/t/t%s/t/t%s" % (i["name"], i["age"],           i["phone"], i["email"]))   revise_cards(i)  else:   print("沒(méi)有查詢到您搜索的信息")def revise_cards(dict_1): """修改名片,接收之前已經(jīng)查到的字典""" while True:  user_choor = input("1.修改名片 2.刪除名片 0.返回主菜單")  if user_choor == "1": # 如果用戶輸入1執(zhí)行修改功能   print("修改名片,注:修改直接輸入修改內(nèi)容,回車不修改")   dict_1["name"] = revise(dict_1["name"], input("姓名"))   dict_1["age"] = revise(dict_1["age"], input("年齡"))   dict_1["phone"] = revise(dict_1["phone"], input("電話"))   dict_1["email"] = revise(dict_1["email"], input("郵箱"))   print("修改成功")   break  # laturn  elif user_choor == "2": # 如果輸入2刪除字典   list_all.remove(dict_1)   print("刪除名片成功")   break  elif user_choor == "0":   break  else:   print("輸入錯(cuò)誤請(qǐng)重新輸入")def revise(old, new): """實(shí)現(xiàn)回車不修改的功能""" if len(new) <= 0:  return old else:  return newdef save_dir(): """將文件保存至指定文件""" a = open("123.xlsx", "w") a.write(str(list_all)) a.close() print("保存成功")def read_dir(): """讀取文件""" if os.path.exists("123.data"):  a = open("123.data", "r")  b = eval(a.read())  global list_all  list_all = b  a.close()import cards_tools# 讀取文件cards_tools.read_dir()while True: cards_tools.page() user_input = input("請(qǐng)選擇您要執(zhí)行的操作") if user_input == "1":  print("即將執(zhí)行:新建名片")  cards_tools.new_cards() elif user_input == "2":  print("即將執(zhí)行:查看全部")  cards_tools.check_all() elif user_input == "3":  print("即將執(zhí)行:查詢名片")  cards_tools.check_cards() elif user_input == "4":  print("即將執(zhí)行:保存信息")  cards_tools.save_dir() elif user_input == "0":  print("歡迎下次使用[名片管理系統(tǒng)]")  exit() else:  print("你的輸入有誤,請(qǐng)重新輸入")            
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临安市| 阳新县| 呼图壁县| 峨边| 永城市| 晋城| 百色市| 伊通| 苏尼特右旗| 睢宁县| 微山县| 鄂州市| 射洪县| 车致| 若羌县| 威信县| 绵阳市| 津市市| 鹰潭市| 屯留县| 潜江市| 东宁县| 基隆市| 临清市| 蛟河市| 盐源县| 建阳市| 鄂托克前旗| 黄冈市| 郑州市| 江津市| 陇南市| 承德市| 临海市| 茶陵县| 云阳县| 临高县| 东平县| 屏边| 丘北县| 平湖市|