Convert Seconds to datetime timedelta [duplicate]

ぃ、小莉子 提交于 2019-12-06 22:39:48

问题


In python how can I simply convert an integer of seconds into (h:m:s) using the datetime module?

i.e. 500000 ---> 138:53:20

Please, no tuple hackery.


回答1:


Maybe this answer from SO will do:

>>> import datetime
>>> str(datetime.timedelta(seconds=500000))
'5 days, 18:53:20'


来源:https://stackoverflow.com/questions/25193464/convert-seconds-to-datetime-timedelta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!