Python Time conversion h:m:s to seconds

后端 未结 7 1084
青春惊慌失措
青春惊慌失措 2021-01-02 11:32

I am aware that with the timedelta function you can convert seconds to h:m:s using something like:

>> import datetime
>> str(datetime.timedelta(s         


        
7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 11:50

    >>> def tt(a):
    ...     b = a.split(':')
    ...     return int(b[0]) * 3600 + int(b[1]) * 60 + int(b[2])
    ... 
    >>> print tt('0:11:06')
    

    666

提交回复
热议问题