需求:

  • 可以查询员工所有信息
  • 可以修改员工信息
  • 可以增加新员工

code:

 import sys,json
# yuangong = {
# "1": ["faker", "22", "11111111111", "mid", "2013-01-01"],
# "2": ["huni", "23", "22222222222", "top", "2014-01-01"],
# "3": ["bang", "24", "33333333333", "adc", "2015-01-01"],
# "4": ["wolf", "25", "44444444444", "sup", "2016-01-01"],
# "5": ["blank", "26", "55555555555", "jun", "2017-01-01"]}
# with open('E:/Staff management.txt','w')as w_f:
# json.dump(yuangong,w_f) salary = {} with open('E:/Staff management.txt', 'r') as read_f:
f_line = json.load(read_f)
#read_f.write(json.dump(salary))
salary = f_line
#print(salary) def append_file():
with open('E:/Staff management.txt', 'r+') as append_f:
json.dump(append_f,salary)
return def write_file():
with open('E:/Staff management.txt', 'w') as write_f:
json.dump(salary,write_f)
return def server():
for i in range(1):
print("1.查询员工信息\n2.修改员工信息\n3.增加新员工信息\n4.删除员工\n5.退出")
return def server_choice(a):
while True:
choice = input("Please input your choice:")
if choice == '':
query()
elif choice == '':
modify()
elif choice == '':
increase()
elif choice == '':
delete()
elif choice == '':
sys.exit("程序已退出,欢迎重新运行")
else:
print("你输入的不存在,请重新输入") def query():
position = input("请输入输入员工编号或按b退回上一层:")
if f_line.get(position):
#print(f_line[position])
print("员工信息:\n名字:%s\n年龄:%s\n电话号码:%s\n职位:%s\n入职时间:%s" % (f_line[position][0],f_line[position][1],f_line[position][2],f_line[position][3],f_line[position][4]))
query()
elif position.lower() == 'b':
server()
else:
print('你输入的编号不存在')
query() def modify():
position = input("Please 要修改的员工编号或者按b退到上一层:")
if f_line.get(position):
correct = input(" 1.name:%s\n 2.age:%s\n 3.phone number:%s\n 4.position:%s\n 5.Entry time:%s\n请输入你要修改的信息:" % (f_line[position][0],f_line[position][1],f_line[position][2],f_line[position][3],f_line[position][4]))
if correct == '':
name = input("请输入你要修改的名字:")
salary[position][0] = name
write_file()
modify()
elif correct == '':
age = input("请输入你要修改的年龄:")
if age.isdigit():
salary[position][1] = age
write_file()
modify()
else:
print("你输入的不是数字,请重新输入")
modify()
elif correct == '':
phone = input("请输入你要修改的电话号码:")
salary[position][2] = phone
write_file()
modify()
elif correct == '':
post = input("请输入你要修改的职位:")
salary[position][3] = post
write_file()
modify()
elif correct == '':
Entry = input("请输入你要修改的入职时间:")
salary[position][4] = Entry
write_file()
modify()
else:
print("Input error,Please re-enter")
modify()
elif position.lower() == 'b':
server()
else:
print("你输入的员工编号不存在,请重新输入")
modify() def increase():
post = []
position = input("请输入你要添加的员工编号或者按b返回:")
if salary.get(position):
print("你输入的编号已存在,请重新输入")
increase()
elif position.isdigit():
name = input("请输入员工姓名:")
age = input("请输入员工年龄:")
phone = input("请输入员工电话号码:")
positioN = input("请输入员工职务:")
Entry = input("请输入员工入职时间:")
post.append(name)
post.append(age)
post.append(phone)
post.append(positioN)
post.append(Entry)
salary[position] = post
write_file()
server()
elif position == 'b':
server()
else:
print("你输入的编号格式不正确(必须为数字),请重新输入:")
increase() def delete():
position = input("请输入你要删除的员工编号或者输入b退到上一层:")
if salary.get(position):
salary.pop(position)
write_file()
print("成功删除")
delete()
elif position == 'b':
server()
else:
print("你输入的编号不存在,请重新输入")
delete() server_choice(server())

Third week-homework(员工管理系统)的更多相关文章

  1. 基于SSM实现的简易员工管理系统(网站上线篇)

    经历无数苦难,好不容易,网站终于上线了.=.=内牛满面ing.chengmingwei.top就是本员工管理系统的主页啦.是的,很简陋,但是毕竟是第一次嘛,所以慢慢来嘛. 如上次所说的(网站简介,见: ...

  2. 基于SSM实现的简易员工管理系统

    之前自学完了JAVA基础,一直以来也没有做什么好玩的项目,最近暑假,时间上比较空闲,所以又学习了一下最近在企业实际应用中比较流行的SSM框架,以此为基础,通过网络课程,学习编写了一个基于SSM实现的M ...

  3. 基于SSH实现员工管理系统之框架整合篇

    本篇文章来源于:https://blog.csdn.net/zhang_ling_yun/article/details/77803178 以下内容来自慕课网的课程:基于SSH实现员工管理系统之框架整 ...

  4. PureMVC和Unity3D的UGUI制作一个简单的员工管理系统实例

    前言: 1.关于PureMVC: MVC框架在很多项目当中拥有广泛的应用,很多时候做项目前人开坑开了一半就消失了,后人为了填补各种的坑就遭殃的不得了.嘛,程序猿大家都不喜欢像文案策划一样组织文字写东西 ...

  5. 5_python之路之员工管理系统

    python之路之员工管理系统 1.程序说明:Readme.cmd 1.程序文件:info_management.py user_info 2.程序文件说明:info_management.py-主程 ...

  6. Java普通员工管理系统

    login GUI界面(登录) package 普通员工管理系统; import java.awt.event.ActionEvent; import java.awt.event.ActionLis ...

  7. 员工管理系统(集合与IO流的结合使用 beta1.0 ArrayList<Employee>)

    package cn.employee; public class Employee { private int empNo; private String name; private String ...

  8. 员工管理系统(集合与IO流的结合使用 beta2.0 ObjectInputStream/ ObjectOutputStream)

    package cn.employee; import java.io.Serializable; public class Employee implements Serializable{ pri ...

  9. 员工管理系统(集合与IO流的结合使用 beta5.0 BufferedReader/ BufferedWriter)

    package cn.gee; public class Emp { private String id;//员工编号 一般是唯一的 private String sname; private int ...

  10. 员工管理系统(集合与IO流的结合使用 beta4.0 ObjectInputStream/ ObjectOutputStream)

    package cn.employee_io; import java.io.Serializable; public class Employee implements Serializable{ ...

随机推荐

  1. ThinkPHP vendor 方法导入第三方类库

    ThinkPHP 3.2 vendor()方法的深入研究及Phpqrcode的正确扩展 ThinkPHP vendor 方法导入第三方类库 第三方类库 第三方类库指除了 ThinkPHP 框架.应用项 ...

  2. openssl-devel和openssl 是什么具体关系

    [转自] https://zhidao.baidu.com/question/919579491101051499.html Redhat在封装openssl的时候,把openssl分成了几个部分,执 ...

  3. cas aqs lock之间的关系

    CAS 对应cpu的硬件指令, 是最原始的原子操作 cas主要是在AtomicInteger AtomicXXX类中使用, 用于实现线程安全的自增操作 ++. 对应一个unsafe对象, 根据os平台 ...

  4. 2.5 References & Borrowing

    Here is how you would define and use a calculate_length function that has a reference to an object a ...

  5. Java调度线程池ScheduleExecutorService

    如果在一个ScheduleExecutorService中提交一个任务,这个任务的调度周期设置 的时间比任务本身执行的时间短的话会出现什么情况?也就是在线程调度时间已经到了 但是上次的任务还没有做完的 ...

  6. 利用wireshark和python分析网络

  7. 60分钟内从零起步驾驭Hive实战学习笔记(Ubuntu里安装mysql)

    本博文的主要内容是: 1. Hive本质解析 2. Hive安装实战 3. 使用Hive操作搜索引擎数据实战 SparkSQL前身是Shark,Shark强烈依赖于Hive.Spark原来没有做SQL ...

  8. How to add more to Git Bash on Windows

    How to add more to Git Bash on Windows Download the lastest wget binary for windows from https://ete ...

  9. Linux之FTP篇

    内容简介: vsftpd的安装 目录介绍 配置参数解释 锁定用户目录 其他用户不能登录 -------------------------------------------------------- ...

  10. document.write与document.getElementById.innterHTML的区别

    <html> <head> <meta charset="utf-8"> <script> var tmp = "< ...