1.主菜单
def __init__(self):
self.workers_info = {}
print("------------功能菜单--------------")
print(" 1:添加职工")
print(" 2:修改信息")
print(" 3:删除信息")
print(" 4:查找职工")
print(" 5:排序")
print(" 6:统计职工总个数")
print(" 7:显示所有职工信息")
print(" 0:退出系统")
2.增加员工信息
def add_workers(self):
name = input('请输入职工姓名')
age = input('请输入职工年龄')
sex = input('请输入职工性别')
phone = input("请输入职工电话号码")
salary = input('请输入职工薪水')
self.workers_info[name] = {
'职工性别': sex,
'职工年龄': age,
'职工电话号码': phone,
'职工薪水': salary
}
self.print_workers(name)
3.查询员工个人信息
def query_only(self):
name = input("请输入要查找的职工姓名")
try:
print(
f"姓名:{name} "
f"职工性别:{self.workers_info[name]['职工性别']} "
f" 职工年龄:{self.workers_info[name]['职工年龄']} "
f"职工电话号码:{self.workers_info[name]['职工电话号码']} "
f"职工薪水:{self.workers_info[name]['职工薪水']} "
)
except:
print("查找职工姓名不存在!!!!!!")
4.删除员工信息
def del_workers(self):
name = input("请输入要删除的职工姓名")
try:
del self.workers_info[name]
except:
print("删除学生姓名不存在!!!!!!")
5.修改员工信息
def change_workers(self):
name = input("请输入要修改的职工姓名:")
try:
self.workers_info[name]['职工年龄'] = input("请修改职工年龄:")
self.workers_info[name]['职工性别'] = input("请修改职工性别:")
self.workers_info[name]['职工电话号码'] = input("请修改职工电话号码:")
self.workers_info[name]['职工薪水'] = input("请修改职工薪水:")
except:
print("修改的职工姓名不存在!!!!!!")
6.计算员工人数
def count(self):
count = 0
for i in enumerate(self.workers_info):
count +=1
print("职工一共有{}人".format(count))
效果图展示
以上就是今天的学习内容啦~
咱们下期再见老铁~
需要定制python大作业可以加一下我QQ2597170348或者微信15060269323!!
感觉还不错的话请一键三连,谢谢!