python面向对象实现名片管理系统文件版
作者:惜美人 时间:2022-11-25 16:27:45
本文实例为大家分享了python实现名片管理系统源代码,供大家参考,具体内容如下
import os
def print_menu():
print("*"*50)
print(" 名片管理系统")
print(" 1.添加一个新名片")
print(" 2.删除一个名片信息")
print(" 3.修改一个名片信息")
print(" 4.查找一个名片信息")
print(" 5.显示添加过的名片信息")
print(" 6.保存添加的名片信息")
print(" 7.退出系统")
print("*"*50)
card_infor = []
def add_new_card_infor():
new_name = input("请输入要添加的名字:")
new_qq = input("请输入Qq:")
new_weixin = input("请输入微信号:")
new_position = input("请输入工作职位")
new_addr = input("请输入工作地址")
"""创建一个字典来存放添加的内容"""
new_infor = {}
new_infor['name'] = new_name
new_infor['qq'] = new_qq
new_infor['weixin'] = new_weixin
new_infor['position'] = new_position
new_infor['addr'] = new_addr
"""将字典刚入一个列表中"""
global card_infor
card_infor.append(new_infor)
def del_card_infor():
del_name =input("请输入要删除的名片")
global card_infor
for temp in card_infor:
if del_name == temp['name']:
print("删除的名片如下")
card_infor.remove(temp)
print("%s\t\t%s\t\t%s\t\t%s\t\t%s"%(temp['name'],temp['qq'],temp['weixin'],temp['position'],temp['addr']))
else:
print("不存在")
return del_card_infor()
def change_care_infor():
change_name_card = input("请输入需要修改的名片名字")
global card_infor
for temp in card_infor:
if change_name_card == temp['name']:
new_name = input("请输入要修改的名字")
new_qq = input("请输入要修改的qq")
new_weixin = input("请输入要修改的微信")
new_position = input("请输入要修改的职业")
new_addr = input("请输入要修改的地址")
temp['name'] = new_name
temp['qq'] = new_qq
temp['weixin'] = new_weixin
temp['position'] = new_position
temp['addr'] = new_addr
print("修改成功")
break
else:
print("您要修改的名片不存在")
def find_card_infor():
global card_infor
find_name = input("请输入要在查找的内容\n")
find = 0
for temp in card_infor:
if find_name == temp['name']:
print("查询成功\n")
print("%s\t\t%s\t\t%s\t\t%s\t\t%s"%(temp['name'],temp['qq'],temp['weixin'],temp['position'],temp['addr']))
find = 1
break
else:
print("您要查询的名片不存在,请重新输入")
return find_card_infor()
def display_card_infor():
global card_infor
print("姓名\t\tQQ\t\t微信\t\t工作\t\t住址")
for temp in card_infor:
print("%s\t\t%s\t\t%s\t\t%s\t\t%s"%(temp['name'],temp['qq'],temp['weixin'],temp['position'],temp['addr']))
def save_card_infor():
global card_infor
f = open("save_card.data","w")
f.write(str(card_infor))
f.close()
def load_card_infor():
"""恢复保存的信息"""
global card_infor
try:
f = open('save_card.data')
card_infor = eval(f.read())
f.close()
except Exception:
pass
def main():
load_card_infor()
"""把恢复保存的信息加载到程序中"""
print_menu()
"""加载首页操作页面"""
while True:
num = int(input("请输入你要选择的功能序号"))
if(num==1):
add_new_card_infor()
elif(num==2):
del_card_infor()
elif(num==3):
change_care_infor()
elif(num==4):
find_card_infor()
elif(num==5):
display_card_infor()
elif(num==6):
save_card_infor()
elif(num==7):
break
else:
print("输入有误,请重新输入")
print()
if __name__ == "__main__":
main()
运行界面
来源:https://blog.csdn.net/qq_41337627/article/details/84929151
标签:python,管理系统
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python 删除系统中的文件(按时间,大小,扩展名)
2022-11-02 23:51:39
SQL Server的复制功能
2024-01-16 19:40:27
![](https://img.aspxhome.com/file/2023/1/94401_0s.jpg)
如何让12px以下的文字最佳显示
2008-01-24 18:39:00
PHP实现的获取文件mimes类型工具类示例
2023-10-07 09:33:33
golang 生成对应的数据表struct定义操作
2024-05-21 10:27:47
价值3亿美元的按钮[译]
2009-03-18 19:39:00
Mysql数据库之索引优化
2024-01-23 19:27:40
![](https://img.aspxhome.com/file/2023/1/107891_0s.png)
pytorch模型预测结果与ndarray互转方式
2023-12-06 02:35:11
Python解析多帧dicom数据详解
2022-08-13 21:16:13
TypeScript类型检查详谈及火爆原因
2022-01-24 11:48:41
![](https://img.aspxhome.com/file/2023/1/131811_0s.png)
JS在IE和FireFox之间常用函数的区别小结
2024-04-16 09:54:54
Oracle 实现类似SQL Server中自增字段的一个办法
2009-08-02 07:51:00
忘记ftp密码使用python ftplib库暴力破解密码的方法示例
2021-01-02 03:08:31
Django项目中动态设置静态文件路径的全过程
2021-07-12 00:52:24
![](https://img.aspxhome.com/file/2023/9/126909_0s.jpg)
SQL高级应用之使用SQL查询Excel表格数据的方法
2024-01-23 09:24:39
OpenCV-Python实现图像梯度与Sobel滤波器
2021-04-07 05:23:20
![](https://img.aspxhome.com/file/2023/5/82535_0s.png)
关于Kotlin中SAM转换的那些事
2022-02-09 15:14:38
浅谈JavaScript窗体Window.ShowModalDialog使用
2024-04-23 09:05:39
SQL"不能为新插入的行确定标识"错误的解决方法
2011-04-07 11:05:00
浅谈Python中文件夹和python package包的区别
2021-03-23 21:57:26
![](https://img.aspxhome.com/file/2023/6/64326_0s.jpg)