python计算工资工时_Python帮助-工时卡脚本/工资计算
感謝您的答復,我嘗試了軍用時間,但我堅持如何獲取python以計算兩次之間的正確分鐘數。
在這里,我將發布到目前為止的代碼。問題是它無法計算正確工作的實際分鐘數的最終值:
def main():
from math import *
from string import *
print "This program calculates the wage earned based on the number of hours worked.\n"
startTime = raw_input("Enter the start time in hours:min format: ")
endTime = raw_input("Enter the end time in hours:min format: ")
#splits time input into usable chunks
startSplit = split(startTime,":")
endSplit = split(endTime,":")
#converts strings to usable integers
startHrs = int(startSplit[0])
startMin = int(startSplit[1])
endHrs = int(endSplit[0])
endMin = int(endSplit[1])
#self explanatory...
startTimeConvert = ((startHrs+12)*100)+startMin
print "The start time conversion is ",startTimeConvert
endTimeConvert = ((endHrs+12)*100)+endMin
print "The end time conversion is ",endTimeConvert
totalTime = endTimeConvert - startTimeConvert
print "Total time is: ",totalTime
#use "0"+str if time is only 3 digits
totalHrs = "0"+str(totalTime)[0:1]
totalMin = "0"+str(totalTime)[2:3]
print "totalHrs test: ",totalHrs
print "totalMin test: ",totalMin
#hourly rate earned
wage = (int(totalHrs)*12.55)+((int(totalMin)*12.55)/60)
#divided min by 60 to get correct wage for minutes portion
print "Wage test: $",wage
if __name__ == '__main__':
main()
我打算將所有內容分成單獨的函數以簡化腳本,但是稍后會出現……在它真正正常工作之后。
任何人都有如何完成代碼并使代碼正確運行的想法嗎?
總結
以上是生活随笔為你收集整理的python计算工资工时_Python帮助-工时卡脚本/工资计算的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jeecgboot关闭swagger
- 下一篇: 有源滤波器和无源滤波器的区别?(硬件每日