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{ ...
随机推荐
- 114th LeetCode Weekly Contest Array of Doubled Pairs
Given an array of integers A with even length, return true if and only if it is possible to reorder ...
- B/S 与 C/S 模型区别
C/S又称Client/Server或客户/服务器模式.服务器通常采用高性能的PC.工作站或小型机,并采用大型数据库系统,如Oracle.Sybase.Informix或 SQL Server.客户端 ...
- 【研究】CVE-2017-11882-Office远程代码执行漏洞复现
实验环境:win10+kali 工具:koadic,Command43b_CVE-2017-11882.py KALI: root@kali:/opt/koadic-master# ./koadic ...
- PIE SDK线元素的绘制
1. 功能简介 在数据的处理中会用到线元素的绘制,目前PIE SDK支持ILineSymbol的线元素的绘制,LineSymbol对象是用于修饰线状对象的符号,它包括CartographicLineS ...
- Activemq API使用(整合spring)
整合spring之后,主要用的就是org.springframework.jms.core.JmsTemplate的API了,在spring-jms-xxx.jar中. 引入整合需要的jar包: &l ...
- 【OpenCV-python】CV2和PIL按box信息实现图像裁剪
# 用cv2实现裁剪 import cv2 import os img = cv2.imread("./test_and_verification/1406170100001.jpg&quo ...
- Excel&&word&&PPT
1. Excel 1.1 制作下拉框 选中单元格或列--> 菜单"数据" --> "数据验证"-->"设置" --> ...
- MYSQ系列-MYSQL基础增强(Mysql基本语句)
MYSQL基础增强 库操作 创建一个使用UTF-8字符集的数据库: create database mydb character set UTF8; 创建一个带校对集的数据库 create datab ...
- Hash索引和B+树索引总结
先说Hash索引 在理想的情况下,key非常分散,不存在Hash碰撞的话,采用Hash索引可以唯一得确定一个key的位置,并且这个位置上就只有一个key,所以查找时间复杂度是O(1),非常快,这是Ha ...
- gcc链接非标准(non-standard)命名库
标准命名库: -lnamespace 标准链接库以lib开头, 并以so/a结尾. example gcc test.c -o test -L. -lhello 非标准命名库: -l:libname ...