class Syestem:
def __init__(self):
self.employees = {}
def register(self):
username = input('请输入用户名:>>>>>>')
password = input('请输入密码:>>>>>>')
print('注册成功')
def login(self):
username = input('请输入用户名:>>>>>>')
password = input('请输入密码:>>>>>>')
print('登录成功')
def add_employee_info(self):
id = input('请输入员工ID:>>>>>>')
name = input('请输入员工姓名:>>>>>>')
money = input('输入员工年薪:>>>>>')
hobby = input('请输入员工爱好:>>>>>>')
self.employees[id] = {'name': name, 'money': money, 'hobby': hobby}
print('信息添加成功')
def search_employee_info(self, id):
if id in self.employees:
print(
f"员工ID: {id}, 姓名: {self.employees[id]['name']}, 年薪: {self.employees[id]['money']},爱好:{self.employees[id]['hobby']}")
else:
print('找不到员工信息')
def search_all_employee_info(self):
for id, info in self.employees.items():
print(f"员工ID: {id}, 姓名: {info['name']}, 年薪: {info['money']},爱好:{info['hobby']}")
def del_employee(self, id):
if id in self.employees:
del self.employees[id]
print('删除成功')
else:
print('找不到员工信息')
def del_all_employee(self):
self.employees.clear()
print('删除所有信息成功')
def change_info(self, id):
if id in self.employees:
new_name = input('请输入新的员工姓名:>>>>>>')
new_money = input('输入新的年薪:>>>>>>')
new_hobby = input("请输入新的爱好:>>>>>")
self.employees[id]['name'] = new_name
self.employees[id]['money'] = new_money
self.employees[id]['hobby'] = new_hobby
print('员工信息修改成功')
else:
print('找不到员工信息')
def exit_system(self):
print('再见')
def main():
dhy = Syestem()
while True:
print("--------------- 欢迎来到梦梦员工系统 ---------------")
print(
"1:注册\n2:登陆\n3:添加员工信息\n4:查看指定员工信息\n5:查看所有员工信息\n6:删除指定员工信息\n7:删除所有员工信息\n8:修改指定员工信息\n9:退出系统")
choice = input('请输入功能ID:>>>>>')
if choice == '1':
dhy.register()
elif choice == '2':
dhy.login()
elif choice == '3':
dhy.add_employee_info()
elif choice == '4':
id = input("请输入员工ID: ")
dhy.search_employee_info(id)
elif choice == '5':
dhy.search_all_employee_info()
elif choice == '6':
id = input("请输入员工ID: ")
dhy.del_employee(id)
elif choice == '7':
dhy.del_all_employee()
elif choice == '8':
id = input("请输入员工ID: ")
dhy.change_info(id)
elif choice == '9':
dhy.exit_system()
break
else:
print("重新输入")
if not choice.isdigit():
print('非法')
if __name__ == '__main__':
main()
标签:employees,管理系统,self,员工,print,input,id,考试
From: https://www.cnblogs.com/dhyuan/p/17934026.html