time conversion

Fredrik Lundh fredrik at pythonware.com
Thu Oct 27 11:03:34 EDT 2005


"flupke" wrote:

> Is there an easy to convert following hour notation hh:mm
> to decimals?
> For instance 2 hours and 30 minutes as 2:30 to 2,50
> I don't really know where to search for this kind of conversion.

you mean like

    >>> timestamp = "2:30"
    >>> hour, minute = timestamp.split(":")
    >>> print int(hour) + int(minute) / 60.0
    2.5

?

</F>






More information about the Python-list mailing list