名片管理系統(tǒng)python版
更新時間:2018年01月11日 09:08:44 作者:WangF0
這篇文章主要為大家詳細(xì)介紹了名片管理系統(tǒng)python版的相關(guān)代碼,數(shù)據(jù)保存導(dǎo)入Excel,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了python名片管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
import os
list_all = []
def page():
"""輸出主頁面"""
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("還沒有任何信息")
def check_cards():
"""查詢名片"""
user = input("請輸入要查詢的姓名:")
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("沒有查詢到您搜索的信息")
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("輸入錯誤請重新輸入")
def revise(old, new):
"""實(shí)現(xiàn)回車不修改的功能"""
if len(new) <= 0:
return old
else:
return new
def 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("請選擇您要執(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("你的輸入有誤,請重新輸入")
更多學(xué)習(xí)資料請關(guān)注專題《管理系統(tǒng)開發(fā)》。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- 詳解Python做一個名片管理系統(tǒng)
- python實(shí)現(xiàn)名片管理系統(tǒng)
- python實(shí)現(xiàn)簡單名片管理系統(tǒng)
- 一個簡單的Python名片管理系統(tǒng)
- python3實(shí)現(xiàn)名片管理系統(tǒng)
- python面向?qū)ο髮?shí)現(xiàn)名片管理系統(tǒng)文件版
- 基于python實(shí)現(xiàn)名片管理系統(tǒng)
- Python實(shí)現(xiàn)名片管理系統(tǒng)
- Python版名片管理系統(tǒng)
- python實(shí)現(xiàn)簡單的名片管理系統(tǒng)
相關(guān)文章
Python庫textract提取各種文檔類型中文本數(shù)據(jù)
Python的textract庫是一個強(qiáng)大的工具,它可以從各種文檔類型中提取文本數(shù)據(jù),無論是PDF、Word文檔、圖片還是其他格式的文件,textract都可以輕松地將文本提取出來,本文將詳細(xì)介紹textract的功能和用法,并提供豐富的示例代碼來幫助大家深入了解2024-01-01
Python實(shí)現(xiàn)的簡單線性回歸算法實(shí)例分析
這篇文章主要介紹了Python實(shí)現(xiàn)的簡單線性回歸算法,結(jié)合實(shí)例形式分析了線性回歸算法相關(guān)原理、功能、用法與操作注意事項(xiàng),需要的朋友可以參考下2018-12-12
Pytorch模型轉(zhuǎn)onnx模型實(shí)例
今天小編就為大家分享一篇Pytorch模型轉(zhuǎn)onnx模型實(shí)例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-01-01
部署django項(xiàng)目安裝uwsgi出錯的解決方法總結(jié)
uwsgi協(xié)議是一個uWSGI服務(wù)器自有的協(xié)議,它用于定義傳輸信息的類型(type of information),每一個uwsgi packet前4byte為傳輸信息類型描述,它與WSGI相比是兩樣?xùn)|西,下面這篇文章主要給大家介紹了關(guān)于部署django項(xiàng)目安裝uwsgi出錯的解決方法,需要的朋友可以參考下2022-08-08

