from datetime import datetime import time all_time = [ "2015.05.26 08:36:52", "2015.05.25 09:36:34", "2015.05.22 08:03:44", "2015.05.21 08:08:13", "2015.05.20 08:06:03", "2015.05.19 07:58:02", "2015.05.18 08:08:17", "2015.05.15 08:15:17", "2015.05.14 08:18:49", "2015.05.13 07:48:25", "2015.05.12 08:01:49", "2015.05.11 09:47:48", "2015.05.08 08:06:03", "2015.05.07 08:02:49", "2015.05.06 07:44:37", "2015.05.05 08:20:55", "2015.05.04 08:41:42", "2015.05.01 08:23:03" ] must_time = ' 08:00:00' money_per_minute = 200 fmt = '%Y.%m.%d %H:%M:%S' total_diff = 0.0 for time in all_time: performance_time = datetime.strptime(time,fmt) planned_time = datetime.strptime(datetime.strftime(performance_time,'%Y.%m.%d') + must_time, fmt) print "-----------" print "performance_time", performance_time print "planned_time", planned_time diff = performance_time - planned_time if performance_time >= planned_time: diff_minutes = (diff.days * 24 * 60) + (diff.seconds/60) print "diff", diff_minutes total_diff += diff_minutes print "Minut:", total_diff print "Hour :", total_diff/60 print "Money Per Minute:", money_per_minute print "Total Money:", money_per_minute*total_diff*-1
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question