python花名册管理系统
时间: 2023-10-13 17:11:29 浏览: 132
好的,一个简单的Python花名册管理系统可以包括以下功能:
1. 添加联系人信息
2. 删除联系人信息
3. 修改联系人信息
4. 查找联系人信息
5. 显示所有联系人信息
6. 退出系统
以下是一个示例代码,用于实现这些功能:
```python
# 定义一个空字典来存储联系人信息
contacts = {}
# 添加联系人信息
def add_contact():
name = input("请输入联系人姓名:")
phone = input("请输入联系人电话号码:")
email = input("请输入联系人电子邮件地址:")
contacts[name] = {"phone": phone, "email": email}
print("联系人信息添加成功!")
# 删除联系人信息
def delete_contact():
name = input("请输入要删除的联系人姓名:")
if name in contacts:
del contacts[name]
print("联系人信息删除成功!")
else:
print("联系人信息不存在!")
# 修改联系人信息
def edit_contact():
name = input("请输入要修改的联系人姓名:")
if name in contacts:
phone = input("请输入新的电话号码:")
email = input("请输入新的电子邮件地址:")
contacts[name]["phone"] = phone
contacts[name]["email"] = email
print("联系人信息修改成功!")
else:
print("联系人信息不存在!")
# 查找联系人信息
def search_contact():
name = input("请输入要查找的联系人姓名:")
if name in contacts:
print("联系人信息如下:")
print("姓名:", name)
print("电话号码:", contacts[name]["phone"])
print("电子邮件地址:", contacts[name]["email"])
else:
print("联系人信息不存在!")
# 显示所有联系人信息
def show_contacts():
print("所有联系人信息如下:")
for name in contacts:
print("姓名:", name)
print("电话号码:", contacts[name]["phone"])
print("电子邮件地址:", contacts[name]["email"])
# 退出系统
def quit_system():
print("感谢使用本系统,再见!")
exit()
# 显示菜单
def show_menu():
print("欢迎使用花名册管理系统!")
print("1. 添加联系人信息")
print("2. 删除联系人信息")
print("3. 修改联系人信息")
print("4. 查找联系人信息")
print("5. 显示所有联系人信息")
print("6. 退出系统")
# 主函数
def main():
while True:
show_menu()
choice = input("请输入您的选择:")
if choice == "1":
add_contact()
elif choice == "2":
delete_contact()
elif choice == "3":
edit_contact()
elif choice == "4":
search_contact()
elif choice == "5":
show_contacts()
elif choice == "6":
quit_system()
else:
print("输入有误,请重新输入!")
if __name__ == '__main__':
main()
```
运行代码后,用户可以根据菜单选择相应的功能,进行花名册管理。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)