python计算工资工时_Python帮助-工时卡脚本/工资计算
感謝您的答復(fù),我嘗試了軍用時(shí)間,但我堅(jiān)持如何獲取python以計(jì)算兩次之間的正確分鐘數(shù)。
在這里,我將發(fā)布到目前為止的代碼。問(wèn)題是它無(wú)法計(jì)算正確工作的實(shí)際分鐘數(shù)的最終值:
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()
我打算將所有內(nèi)容分成單獨(dú)的函數(shù)以簡(jiǎn)化腳本,但是稍后會(huì)出現(xiàn)……在它真正正常工作之后。
任何人都有如何完成代碼并使代碼正確運(yùn)行的想法嗎?
總結(jié)
以上是生活随笔為你收集整理的python计算工资工时_Python帮助-工时卡脚本/工资计算的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: jeecgboot关闭swagger
- 下一篇: python爬虫网站接口的使用——将网页