首页 > 代码库 > module1-工资管理系统
module1-工资管理系统
#!/usr/local/bin/python3 # -*- coding:utf-8 -*- # AUTHOR:Howard hao import os,shutil print(‘欢迎进入工资管理系统‘) def help_show(): print("1.查询员工工资\n2.修改员工工资\n3.增加新员工记录\n4.退出") print("键入数字进入对应菜单,二级菜单下键入空值返回上一层菜单。") while True: help_show() Num = input("Your input is:") if Num == ‘1‘: print(‘进入工资查询界面‘) while True: Name = input(‘你要查询的员工是:‘) with open(‘info.txt‘, ‘r‘) as f1: f2 = f1.read() if not Name in f2: print(‘该员工不存在‘) continue if Name.strip() == ‘‘: break with open(‘info.txt‘,‘r‘) as f: for i in f: if Name in i: I = i.split() salary = I[1] print(‘%s的工资为:%s‘ %(Name,salary)) elif Num == ‘2‘: print(‘进入工资修改界面‘) while True: Name = input(‘你要修改工资的员工是:‘) with open(‘info.txt‘, ‘r‘) as f1: f2 = f1.read() if not Name in f2: print(‘该员工不存在‘) continue if Name.strip() == ‘‘: break salary = input(‘想修改成:‘) if Name.strip() == ‘‘: break f = open(‘info.txt‘, ‘r‘) f1 = open(‘info_update‘,‘w‘) for i in f: if Name in i: i = ‘%s %s\n‘ %(Name,salary) f1.write(i) BASE_DIR = os.path.dirname(__file__) f.close() f1.close() shutil.copy(‘info_update‘,‘info.txt‘) elif Num == ‘3‘: print(‘进入增加新纪录界面‘) while True: Name = input(‘新员工名字:‘) if Name.strip() == ‘‘: break salary = input(‘新员工薪水:‘) if Name.strip() == ‘‘: break with open(‘info.txt‘, ‘a‘) as f: i = ‘\n%s %s‘ % (Name,salary) f.write(i) elif Num == ‘4‘: exit() elif Num.strip() == ‘‘: exit()
本文出自 “ProgressEveryd” 博客,请务必保留此出处http://987774031.blog.51cto.com/11704329/1941624
module1-工资管理系统
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。