python学习之工资结算-创新互联
import os,re,sys
创新互联主营宜丰网站建设的网络公司,主营网站建设方案,成都app软件开发公司,宜丰h5成都微信小程序搭建,宜丰网站营销推广欢迎宜丰等地区企业咨询operation_lists = '''
1.查询工资
2.修改工资
3.增加新员工记录
4.删除员工信息
5.退出
'''
user_dict = {}
user_name = []
def user_information():
with open('info.txt','r',encoding='UTF-8') as f :
f = f.readlines()
for i in f:
i = i.strip()
i = i.split()
global user_name
user_name.append(i[0])
user_dict[i[0]] = i[1]
print(user_name)
def operation():
while True:
print(operation_lists)
user_operation = input('请输入你的操作编号:')
if user_operation.isdigit():
user_operation = int(user_operation)
if user_operation > 5:
print('你在搞什么,不要乱搞')
if user_operation == 1:
user_enquires()
if user_operation == 2:
salary_change()
if user_operation == 3:
add_users()
if user_operation == 4:
del_users()
if user_operation == 5:
sys.exit('退出程序')
else:
print('不要搞事情')
def user_enquires():
user_information()
name_key = input('输入你想查询人员的名字:')
global user_dict
print('%s的工资为%s'%(name_key,user_dict.get(name_key)))
def salary_change():
user_information()
name_key = input('输入你想改变人员工资的名字:')
print('%s的工资为%s' % (name_key, user_dict.get(name_key)))
salary_change = input('请输入该员工新的金额:')
if salary_change.isdigit():
salary_change = int(salary_change)
with open('info.txt','r',encoding='UTF-8') as fa :
lines = fa.readlines()
with open('info.txt','w',encoding='UTF-8') as f_w:
for line in lines:
if name_key in line:
name_salay = str(user_dict.get(name_key))
print(name_salay)
salary_change = str(salary_change)
line = line.replace(name_salay,salary_change)
f_w.write(line)
user_dict[name_key] = salary_change
print(user_dict)
else:
print('能不能不搞事????')
def add_users():
user_information()
user_name = input('请输入你要添加人员的姓名:')
user_salary = input('请你给他开工资:')
if user_salary.isdigit():
user_salary = int(user_salary)
else:
print('能不能不搞事!!')
user_dict[user_name] = user_salary
def del_users():
user_information()
user_name = input('请输入你要删除员工的姓名:')
user_dict.pop(user_name)
operation()
#user_information()
#user_enquires()
#salary_change()
#add_users()
#user_information()
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
文章题目:python学习之工资结算-创新互联
标题URL:http://pwwzsj.com/article/cdoogo.html