Third week-homework(员工管理系统)
需求:
- 可以查询员工所有信息
- 可以修改员工信息
- 可以增加新员工
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(员工管理系统)的更多相关文章
- 基于SSM实现的简易员工管理系统(网站上线篇)
经历无数苦难,好不容易,网站终于上线了.=.=内牛满面ing.chengmingwei.top就是本员工管理系统的主页啦.是的,很简陋,但是毕竟是第一次嘛,所以慢慢来嘛. 如上次所说的(网站简介,见: ...
- 基于SSM实现的简易员工管理系统
之前自学完了JAVA基础,一直以来也没有做什么好玩的项目,最近暑假,时间上比较空闲,所以又学习了一下最近在企业实际应用中比较流行的SSM框架,以此为基础,通过网络课程,学习编写了一个基于SSM实现的M ...
- 基于SSH实现员工管理系统之框架整合篇
本篇文章来源于:https://blog.csdn.net/zhang_ling_yun/article/details/77803178 以下内容来自慕课网的课程:基于SSH实现员工管理系统之框架整 ...
- PureMVC和Unity3D的UGUI制作一个简单的员工管理系统实例
前言: 1.关于PureMVC: MVC框架在很多项目当中拥有广泛的应用,很多时候做项目前人开坑开了一半就消失了,后人为了填补各种的坑就遭殃的不得了.嘛,程序猿大家都不喜欢像文案策划一样组织文字写东西 ...
- 5_python之路之员工管理系统
python之路之员工管理系统 1.程序说明:Readme.cmd 1.程序文件:info_management.py user_info 2.程序文件说明:info_management.py-主程 ...
- Java普通员工管理系统
login GUI界面(登录) package 普通员工管理系统; import java.awt.event.ActionEvent; import java.awt.event.ActionLis ...
- 员工管理系统(集合与IO流的结合使用 beta1.0 ArrayList<Employee>)
package cn.employee; public class Employee { private int empNo; private String name; private String ...
- 员工管理系统(集合与IO流的结合使用 beta2.0 ObjectInputStream/ ObjectOutputStream)
package cn.employee; import java.io.Serializable; public class Employee implements Serializable{ pri ...
- 员工管理系统(集合与IO流的结合使用 beta5.0 BufferedReader/ BufferedWriter)
package cn.gee; public class Emp { private String id;//员工编号 一般是唯一的 private String sname; private int ...
- 员工管理系统(集合与IO流的结合使用 beta4.0 ObjectInputStream/ ObjectOutputStream)
package cn.employee_io; import java.io.Serializable; public class Employee implements Serializable{ ...
随机推荐
- 【Python】struts2-045批量检测
0x00 环境 存在struts2-045漏洞的war包 apache-tomcat 0x01 脚本 #coding:utf-8 import re import urllib import ...
- Gym - 100989
B Although Haneen was able to solve the LCS problem, Dr. Ibrahim is suspicious about whether she rea ...
- iView 初识
iView和element-UI在table这块有有相似之处,但是与layui有不同的地方 在data数据这里有明显的不同,在iView中data数组下每个元素对象对应一行的数据:而layui中,da ...
- css垂直居中几种方法(二)
方法1:table-cell .box1{ display: table-cell; vertical-align: middle; text-align: center; } <div cla ...
- oracle 基础知识(四) 构成
一, oracle服务 一个oracle 服务由一个oracle 实例和一个oracle数据库组成. oracle = instance + database 总体概念: 二, oracle 实例 0 ...
- TOJ 2711 Stars
描述 Astronomers often examine star maps where stars are represented by points on a plane and each sta ...
- Android多语言与国际化
internationalization (国际化)简称 i18n,因为在i和n之间还有18个字符,localization(本地化 ),简称L10n.一般用 语言_地区的形式表示一种语言,如 zh_ ...
- CentOS 6.5 安装MySQL数据库
CentOS 6.5 安装MySQL数据库 [root@seeker~]# yum -y install mysql-server //安装命令 [root@seeker~]# service mys ...
- JS常用的设计模式(6)——桥接模式
桥接模式的作用在于将实现部分和抽象部分分离开来, 以便两者可以独立的变化.在实现api的时候, 桥接模式特别有用.比如最开始的singleton的例子. var singleton = functio ...
- SQL Exists 的用法 转载
比如在Northwind数据库中 有一个查询为 SELECT c.CustomerId, CompanyName FROM Customers c WHERE EXISTS( SELECT O ...