Python的timedelta:我不能在任何时间单位得到我想要的全部差异的价值? [英] Python's timedelta: can't I just get in whatever time unit I want the value of the entire difference?
问题描述
根据文档,我必须使用days属性AND秒属性来获取花哨的日期字符串想。
我不能在任何时间单位得到整个差异的价值?我错过了什么吗?
如果我能够在几秒钟内获得整体差异,这将是完美的。
似乎Python 2.7引入了一个 total_seconds()方法,这是你正在寻找的,我相信!
I am trying to have some clever dates since a post has been made on my site ("seconds since, hours since, weeks since, etc..") and I'm using datetime.timedelta difference between utcnow and utc dated stored in the database for a post.
Looks like, according to the docs, I have to use the days attribute AND the seconds attribute, to get the fancy date strings I want.
Can't I just get in whatever time unit I want the value of the entire difference? Am I missing something?
It would be perfect if I could just get the entire difference in seconds.
It seems that Python 2.7 has introduced a total_seconds() method, which is what you were looking for, I believe!
这篇关于Python的timedelta:我不能在任何时间单位得到我想要的全部差异的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!