# -*- coding:utf-8 -*-
__author__ = ‘CN092357‘
def query():
f = open("info", "r+", encoding="utf-8")
name = input("请输入要查询的员工姓名(例如:Alex):")
for line in f:
if name in line:
print("%s的工资是:%s。" % (line.split()[0], line.split()[1]))
f.close()
def change():
f = open("info", "r", encoding="utf-8")
f_new = open("info.bak", "w", encoding="utf-8")
new_salary = input("请输入要修改的员工姓名和工资,用空格分隔(例如:Alex 10):")
for line in f:
if new_salary.split()[0] in line:
line = "%s\n" % new_salary
print("修改成功!")
f_new.write(line)
f.close()
f_new.close()
f = open("info", "w", encoding="utf-8")
f_new = open("info.bak", "r", encoding="utf-8")
for line in f_new:
f.write(line)
f.close()
f_new.close()
def add():
f = open("info", "a", encoding="utf-8")
new_record = input("请输入要增加的员工姓名和工资,共空格分割(例如:Eric 100000):")
f.write("\n\n%s" % new_record)
print("增加成功!")
f.close()
list = [‘查询员工工资‘,‘修改员工工资‘,‘增加新员工记录‘,‘退出‘]
exit_flag = False
while not exit_flag:
for i in list:
print("%s. %s" % (list.index(i) + 1, i))
choose = input()
if choose == "1":
query()
if choose == "2":
change()
if choose == "3":
add()
if choose == "4":
print("再见!")
exit_flag = True
‘‘‘
for a in f.readlines():
print(a.strip())
‘‘‘
工资系统
Posted hardy-lu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了工资系统相关的知识,希望对你有一定的参考价值。
以上是关于工资系统的主要内容,如果未能解决你的问题,请参考以下文章