需求:

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

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. 113th LeetCode Weekly Contest Largest Time for Given Digits

    Given an array of 4 digits, return the largest 24 hour time that can be made. The smallest 24 hour t ...

  2. SPOJ - MAXXOR

    依然是异或运算,这次是限制L,R范围内挑2个数使其异或值最大 如果r最高为是pos,那最理想状态当然是(1ll<<pos+1)-1 只有2个数如果凑近最理想的状态?直接找紧挨着的一个就好, ...

  3. Wscript的popup

    Dim WSHShell Set WSHShell = WScript.CreateObject("WScript.Shell") WshSHell.popup "枚举主 ...

  4. HTML5实现多文件的上传示例代码

    [转自] http://www.jb51.net/html5/136791.html 主要用到的是<input>的multiple属性 代码如下: <input type=" ...

  5. centeros下安装python3

    一.查看python版本及安装python3 1. which python 可以看到预装的是2.7版本 2.安装依赖包 yum -y groupinstall "Development t ...

  6. java中的线程(3):线程池类 ThreadPoolExecutor「线程池的类型、参数、扩展等」

    官方文档: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html 1.简介 pu ...

  7. Java中使用nextLine(); 没有输入就自动跳过的问题

    转自:https://www.cnblogs.com/1020182600HENG/p/6564795.html [问题分析] 必要的知识:in.nextLine();不能放在in.nextInt() ...

  8. MySql——Explain执行计划详解

    使用explain关键字可以模拟优化器执行SQL查询语句,从而知道MySQL是如何处理你的SQL语句的,分析你的查询语句或是表结构的性能瓶颈. explain执行计划包含的信息 其中最重要的字段为:i ...

  9. (转)CentOS 7 sytemctl 自定义服务开机启动

    CentOS 7 sytemctl 自定义服务开机启动 原文:http://blog.csdn.net/ithomer/article/details/51766319 CentOS 7继承了RHEL ...

  10. 015-GenericEncodingFilter模板【解决全局乱码】

    package ${enclosing_package}; import java.io.IOException; import java.io.UnsupportedEncodingExceptio ...