How can I get hours from a Python datetime?
h = d.hour + d.minute / 60. + d.second / 3600.
has less brackets…
h = (d - d.replace(hour=0,minute=0,second=0)).seconds / 3600.
... has less division and/or multiplication
h = d.hour + d.minute / 60. + d.second / 3600.
has less brackets…
h = (d - d.replace(hour=0,minute=0,second=0)).seconds / 3600.
... has less division and/or multiplication