【Python】生死簿管理系统,估值5毛,简爱7g(生死簿源码)
0evadmin
编程语言
10
文件名:【Python】生死簿管理系统,估值5毛,简爱7g
【Python】生死簿管理系统,估值5毛
生死簿管理系统 代码 """生死簿管理系统"""import osimport timefile_name = 'data.txt'def main():while True:main_menu()choice = (int)(input("请选择: "))if choice in [0, 1, 2, 3, 4, 5, 6, 7]:if choice == 0:answer = input("确定要退出生死簿系统吗?y/n ")if answer.lower() == 'y':print("已退出!!!")breakelse:continueelif choice == 1:add()passelif choice == 2:passelif choice == 3:delete()passelif choice == 4:passelif choice == 5:passelif choice == 6:passelif choice == 7:passelse:print("")def main_menu():print("=============================生死簿管理系统=============================")print("-----------------------------功能菜单-----------------------------")print("1.录入人员")print("2.查找人员")print("3.删除人员")print("4.修改人员")print("5.排序")print("6.统计总人数")print("7.查询所有")print("0.退出")print("----------------------------------------------------------------")def add():person = {}while True:person_id = input("请输入人员ID: ")if not id:print("id不能为空")continueelse:person["id"] = person_idbreakwhile True:name = input("请输入人员姓名: ")if not name:print("id不能为空")continueelse:person["name"] = namebreakwhile True:num = input("请输入人员阳寿: ")if not num:print("阳寿不能为空")continueelse:person["num"] = numbreak# 保存数据save_data(person)# 是否继续添加s = input("是否继续添加人员?y/n ")if s.lower() == 'y':add()else:main()passdef save_data(person):print("数据保存中。。。")try:# 追加file_stream = open(file_name, 'a', encoding="utf-8")except Exception as e:# 写入file_stream = open(file_name, 'w', encoding="utf-8")print("数据保存成功。。。")# 写入 数据状态person['yn'] = 1# 创建时间person['create_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())file_stream.write(str(person) + "\n")# 关闭文件file_stream.close()passdef search():passdef delete():while True:person_id = input("请输入要删除的人员ID:")person_list = []if person_id != '' and person_id is not None:if os.path.exists(file_name):with open(file_name, 'r', encoding="utf-8") as file:person_list = file.readlines()else:pass# 定义是否被删除del_flag = Falseif person_list:# w模式会清空内容with open(file_name, 'w', encoding="utf-8") as wfile:for item in person_list:# 转为dict类型d = dict(eval(item))if d['id'] != person_id:wfile.write(str(d) + "\n")else:del_flag = Trueif del_flag:print(f"ID为{person_id}的人员已删除!!!")else:print(f'ID为{person_id}的人员不存在!!!')else:print(f'ID为{person_id}的人员不存在!!!')breakquery_all()while True:answer = input("是否继续删除?y/n ")if answer == '' or answer is None:continueelse:breakif answer.lower() == 'y':continueelse:breakelse:print("ID不能为空")passdef modify():passdef sort():passdef total():passdef query_all():passif __name__ == '__main__':main() 打包可执行文件 pip3 install PyInstallerpyinstaller -F /Users/kw/kwzone/Python/code/python-hello/实操篇/BookOfLifeAndDeath/bookmgr.py
同类推荐
-

【Python CheckiO 题解】Striped Words,acer 3810t
查看 -
![【Python 必会技巧】[i for i in range(1,10)] — 列表解析式,列表中使用 for 循环,phiaton](https://wap.0ev.cc/zb_users/cache/thumbs/23e6181118b51d9a0b36fcaeaa9a7ece-80-80-1.jpg)
【Python 必会技巧】[i for i in range(1,10)] — 列表解析式,列表中使用 for 循环,phiaton
查看 -

【Python 自动化】自媒体剪辑第一版·思路简述与技术方案,smart cover
查看 -

【Python-批量修改视频分辨率】,优米umi x1
查看 -

【PythonGIS】基于Python面矢量转换线矢量,堆栈式cmos
查看 -

【Python】 pdf2image中所需要的poppler文件,vx580w
查看 -

【Python】Flask + MQTT 实现消息订阅发布,ipad3发布
查看 -

【Python】IDE环境Pycharm运行虚拟环境Django,天语w606(pycharm使用虚拟环境)
查看 -

【Python】Python开发微信小程序,硕美科g945
查看