簡單的工資管理系統小程式,只是練手

2022-08-10 02:51:16 字數 3362 閱讀 3254

需求如下:

工資管理系統

aaa 100000

bbb 80000

ccc 50000

ddd 30000

-----以上是info.txt檔案-----

實現效果:

從info.txt檔案中讀取員工及其工資資訊,最後將修改或增加的員工工資資訊

也寫入原info.txt檔案。

效果演示:

1. 查詢員工工資

2. 修改員工工資

3. 增加新員工記錄

4. 退出

1

#!/usr/bin/env python2#

-*- coding:utf-8 -*-3#

@time : 2017/9/21 15:194#

@author : lichuan5#

@file : salary.py67

importos8

2526

defselect(read,write):

27 i=input("

please input the employee name:

").strip()

28for line in

read:

29if i ==line.split()[0]:

30print("

%s的工資是:%s

" % (line.split()[0],line.split()[1]))

31return

32print("

輸入錯誤,請重試!")

33read.seek(0)

34select(read, write)

3536

defmodify(read,write):37#

import os

38 flag_tag=true

39 m=input("

請輸入要修改的員工姓名和工資,以空格分隔

").strip().split()

40if len(m) !=2:

41print("

輸入錯誤,請重試,以空格分隔!")

42modify(read,write)

43return

44for i in

read:

45if i.split()[0] == m[0] and m[1].isdigit():

46 flag_tag=false

47 i = "

%s %s\n

" % (m[0], m[1])

48write.write(i)

49if

flag_tag:

50print("

輸入錯誤,請重試!")

51read.seek(0)

52write.seek(0)

53modify(read,write)

54else:55

read.close()

56write.close()

57 os.remove("

info.txt")

58 os.rename("

.swap

", "

info.txt")

5960

6162

defadd(read,write):63#

import os

64 a=input("

請輸入員工姓名和工資,以空格分隔

").strip().split()

65if len(a) !=2:

66print("

輸入錯誤,請重試,以空格分隔!")

67add(read,write)

68return

6970

for i in

read:

71if i.split()[0] ==a[0]:

72print("

使用者已存在,請重新新增新使用者!")

73read.seek(0)

74write.seek(0)

75add(read,write)

76return

77write.write(i)

78 write.write("

\n%s %s

" %(a[0],a[1]))

79read.close()

80write.close()

81 os.remove("

info.txt")

82 os.rename("

.swap

","info.txt")

8384

8586

defout(read,write):

8788

print("

再見!")89

#flag_tag=false

9091 item=

9798 fun=

104105 flag_tag=true

106107

while

flag_tag:

108for i in range(1,5):

109print("

%d, %s

" %(i,item[i]))

110 choice=input("

請選擇:

").strip()

111 with open('

info.txt

','r

',encoding="

utf-8

") as r_read,open('

.swap

','w

',encoding="

utf-8

") as r_write:

112if choice.isdigit() and int(choice) >=1 and int(choice)<4:

113 choice=int(choice)

114fun[choice](r_read,r_write)

115continue

116elif choice.isdigit() and int(choice) == 4:

117 flag_tag=false

118fun[int(choice)](r_read,r_write)

119break

120else

:121

print("

wrong input,try again!")

122continue

123 flag_tag=false

職工工資管理系統程式

編寫乙個職工工資管理系統程式,該程式輸入職工工號和應發工資,由系統對其完成的實發工資實現計算。其中職工資訊包括職工號 姓名 性別 應發工資 稅金 實發工資等 職工號不重複 功能要求及說明 系統以選單方式工作 職工基本資訊和應發工資的錄入功能 用檔案儲存 從鍵盤輸入資料,建立磁碟資料檔案salary....

python day1 簡單的工資管理系統

工資管理系統 alex 100000 rain 80000 egon 50000 yuan 30000 以上是info.txt檔案 實現效果 從info.txt檔案中讀取員工及其工資資訊,最後將修改或增加的員工工資資訊也寫入原info.txt檔案。效果演示 1.查詢與修改員工工資 2.增加新員工工資...

免費的工資管理系統,適合行業薪酬管理特點

新稅改革後的薪酬計算本就複雜,加之行業特殊性,連鎖行業薪酬hr今年日子並不好過 a企業是一家覆蓋全國三十多個城市的食品連鎖企業,擁有百餘家線下分布於各地的直營門店,hr經常出現員工薪資錯誤 人www.cppcns.com力成本不穩定的情況。為此,總部負責人表示,希望選擇一款適合行業薪酬管理特點的工資...