Python timedelta秒与total_seconds [英] Python timedelta seconds vs total_seconds
本文介绍了Python timedelta秒与total_seconds的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
查看日期时间文档,我无法似乎得到了属性 seconds
和timedelta对象上使用的方法 total_seconds()
之间的区别。只是精度吗?开始前者是 int ,而后者是 float ?还是我错过了什么?
Looking at the datetime docs, I can't seem to get the difference between the attribute seconds
and the method total_seconds()
used on a timedelta object. Is it just precision? Begin that the former is and int and the latter a float? Or am I missing something?
推荐答案
秒
是秒数一天之内,即[0,86399]。 total_seconds
是转换为秒的整个时间增量,可以是任何值,例如一周的604800.0或100毫秒的0.1。
seconds
is the number of seconds within a day, which is in [0, 86399]. total_seconds
is the entire timedelta converted to seconds, and can be any value, for example 604800.0 for one week, or 0.1 for 100 milliseconds.
这篇关于Python timedelta秒与total_seconds的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文