Python Time conversion h:m:s to seconds

后端 未结 7 1205
青春惊慌失措
青春惊慌失措 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:52

    You don't need to import anything!

    def time(s):
      m = s // 60
      h = (m // 60) % 60
      m %= 60
      s %= 60
      return h,m,s
    

提交回复
热议问题