计算经过的时间 [英] Calculating Elapsed Time
问题描述
您好 -
我的开始和结束时间是使用
写的:
time.strftime(%b%d%Y%H:%M:%S)
如何计算经过的时间?
>
JJ
__________________________________________
Yahoo! DSL?写点回家的东西。
只需16.99美元/月。或更少。
dsl.yahoo.com
Hello -
I have a start and end time that is written using the
following:
time.strftime("%b %d %Y %H:%M:%S")
How do I calculate the elapsed time?
JJ
__________________________________________
Yahoo! DSL ? Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
推荐答案
16.99 /月。或更少。
dsl.yahoo.com
16.99/mo. or less.
dsl.yahoo.com
2005年12月6日星期二12:36:55 -0800(太平洋标准时间),Jean Johnson< je *********** @ yahoo.com>写道:
On Tue, 6 Dec 2005 12:36:55 -0800 (PST), Jean Johnson <je***********@yahoo.com> wrote:
你好 -
我有一个使用
以下编写的开始和结束时间:
time.strftime("%b%d%Y%H:%M:%S")
如何计算经过的时间?
Hello -
I have a start and end time that is written using the
following:
time.strftime("%b %d %Y %H:%M:%S")
How do I calculate the elapsed time?
tf1 = time.strftime("%b%d%Y%H:%M:%S")
tf1
''Dec 06 2005 14:07: 11''t1 = time.strptime(tf1,"%b%d%Y%H:%M:%S")
tt1
(2005,12,6,14,7,11 ,1,340,-1)t1 = time.mktime(tt1)
t1
1133906831.0 tf2 = time.strftime("%b%d%Y%H:%M:%S")
tf2
''Dec 06 2005 14:08:34''t2 = time.strptime(tf2,"%b%d%Y%H:%M:%S")
tt2
(2005,12,6,14,8,34,1,340,-1)t2 = time.mktime(tt2)
t2
1133906914.0 t2-t1
83.0
(已过去几秒)
在使用stftime之前,也许时间可用作数字?例如,t2可以往返:time.ctime(t2)
''Tue Dec 06 14:08:34 2005''time.strftime("%b%d%Y%H:%M:%S" ;,time.localtime(t2))
''Dec 06 2005 14:08:34''time.strftime("%b%d%Y%H:%M:%S",time.gmtime (t2))
tf1 = time.strftime("%b %d %Y %H:%M:%S")
tf1 ''Dec 06 2005 14:07:11'' tt1 = time.strptime(tf1, "%b %d %Y %H:%M:%S" )
tt1 (2005, 12, 6, 14, 7, 11, 1, 340, -1) t1 = time.mktime(tt1)
t1 1133906831.0 tf2 = time.strftime("%b %d %Y %H:%M:%S")
tf2 ''Dec 06 2005 14:08:34'' tt2 = time.strptime(tf2, "%b %d %Y %H:%M:%S" )
tt2 (2005, 12, 6, 14, 8, 34, 1, 340, -1) t2 = time.mktime(tt2)
t2 1133906914.0 t2-t1 83.0
(seconds elapsed)
Perhaps time was available as a number before stftime was used? E.g., t2 can round trip: time.ctime(t2) ''Tue Dec 06 14:08:34 2005'' time.strftime("%b %d %Y %H:%M:%S", time.localtime(t2)) ''Dec 06 2005 14:08:34'' time.strftime("%b %d %Y %H:%M:%S", time.gmtime(t2))
''Dec 06 2005 22:08:34''
了解更多信息,请参阅时间模块文档
http ://www.python.org/doc/current/lib/module-time.html
一般来说,学习如何从
http://www.python.org/doc/
,互动,
导入时间
帮助(时间)
此致,
Bengt Richter
''Dec 06 2005 22:08:34''
for more info, see time module docs at
http://www.python.org/doc/current/lib/module-time.html
and in general, learn how to find info starting at
http://www.python.org/doc/
also, interactively,
import time
help(time)
Regards,
Bengt Richter
"请注意,即使时间总是作为浮点返回
数字所有系统都提供的时间精度高于1
秒。说文件。
如果确实你的系统返回了,那么可以说任何关于精度的事吗
小数点后的数字?
Thx。
malv
"Note that even though the time is always returned as a floating point
number, not all systems provide time with a better precision than 1
second." says the doc.
Can anything be said about precision if indeed your system returns
figures after the decimal point?
Thx.
malv
这篇关于计算经过的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!