from Tkinter import *
from datetime import datetime
from datetime import timedelta
import math
rate1 = str(35.34)
amp = 2.40
pmp = 2.50
signOnSun1 = raw_input("What time did you sign on Sunday: ");
signOffSun1 = raw_input("What time did you sign off Sunday: ");
if (signOnSun1 < 0600):
rate1 = rate1 + amp
elif (signOnSun1 > 1100):
rate1 = rate1 + pmp
elif (signOffSun1 > 1800):
rate1 = rate1 + pmp
else:
rate1 = 35.34
FMT = '%H%M'
timeWorkedSun1 = ((datetime.strptime(signOffSun1, FMT)) - (datetime.strptime (signOnSun1, FMT)))
*我想timeWorkedSun1轉換爲浮動,所以我可以用率1繁殖,但它似乎是我一生的禍根。任何想法?*轉換時間輸出到一個浮點型變量(Python)的
浮動的是什麼?小時?秒?每天的部分? – Gagravarr
所以我收到的輸出格式爲00:00:00。這很棒。但例如如果格式說8:00:00我想能夠乘以浮動。例如8:00:00 * 34.45不起作用。所以我基本上是在計算我每天工作的小時數,並將其與我的小時費率相乘。多數民衆贊成在目標 –