Ich möchte von einem Format wie 2015-12-09 12: 40: 08
(es scheint ISO-Format zu heißen) in datetime konvertieren.
Referenz http://qiita.com/shibainurou/items/0b0f8b0233c45fc163cd
http://ideone.com/IaAbuS
from datetime import datetime as dt
strdt1 = "2015-12-09 12:40:08"
strdt2 = "2015-12-09 12:35:08"
tdt1 = dt.strptime(strdt1, "%Y-%m-%d %H:%M:%S")
tdt2 = dt.strptime(strdt2, "%Y-%m-%d %H:%M:%S")
print tdt1
print tdt2
print tdt1 - tdt2
Ergebnis
Success time: 0.02 memory: 9184 signal:0
2015-12-09 12:40:08
2015-12-09 12:35:08
0:05:00