日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python 工资管理软件_4_python之路之模拟工资管理系统

發布時間:2023/12/15 python 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 工资管理软件_4_python之路之模拟工资管理系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

#!/usr/bin/env python#_*_ coding: utf-8 _*_#author:chenjianwen#email:1071179133@qq.com

importsys,os##定義操作列表

ops = ['查詢員工工資','修改員工工資','增加新員工記錄','退出']

info={}defget_info():##讀取文件得到員工信息

globalinfo

with open('info.txt',mode='r',encoding='utf-8') as f_r:for line inf_r:

line= line.rstrip('\n')ifline:

name= line.split(' ')[0]

slary= line.split(' ')[1]

info[name]={'name':'%s'%name,'slary':'%s'%slary,'other':''}##定義寫操作函數

defwrite(name,slary):

with open('info.txt', mode='a+', encoding='utf-8') as f_w:

f_w.write('\n%s %s'%(name,slary))##定義修改員工信息函數

defreplace(old_name,new_name,old_slary,new_slary):

f_r= open('info.txt',mode='r',encoding='utf-8')

f_w= open('info1.txt', mode='w+', encoding='utf-8')for line inf_r:

line=line.strip()if old_name inline:

line=line.replace(old_name,new_name)

line=line.replace(old_slary,new_slary)

f_w.write(line+ '\n')

f_r.close()

f_w.close()whileTrue:

get_info()##打印操作菜單

for key,ops_lists inenumerate(ops):print(key,ops_lists,)

select= input("請選擇操作序號:")ifselect.isdigit():pass

else:print("請輸入數字")continue

if select.startswith('0'):

input1= input("請輸入員工名字:")print("%s的工資是:%s" %(input1,info[input1]['slary']))continue

elif select.startswith('1'):

input1= input("請輸入修改員工的名字:")print("%s現在的信息是:名字:%s,工資:%s"%(input1,info[input1]['name'],info[input1]['slary']))

input2= input("名字修改為:")

input3= input("工資修改為:")

replace(input1, input2,info[input1]['slary'], input3)

os.remove('info.txt')

os.rename('info1.txt','info.txt')print("員工信息修改成功")

get_info()continue

elif select.startswith('2'):

input1= input("請輸入增加員工的名字:")

input2= input("請輸入增加員工的工資:")

write(input1,input2)print("新增員工信息成功")

get_info()continue

elif select.startswith('3'):print("退出成功")

sys.exit(1)

總結

以上是生活随笔為你收集整理的python 工资管理软件_4_python之路之模拟工资管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。