初学者,求一程序润色
2009-11-15 13:20:19 来自: 凌虚|advance(united & dialectical mind)
我是高中生,今年高三。这个是本人暑假时做英语阅读使用的秒表(2009年8月3日制作)。凭直觉觉得这个程序有瑕疵,但自己发现不了。所以来到这里,望高手赐教。
(使用方法:回车开始,再回车停止,再回车重新开始……。输入非空字符串回车结束。其实这个程序好理解)
from time import clock
clak1,clak2,tmstr,flag=0,0,'',False
while not tmstr:
tmstr = raw_input() # Just wait it
clak2=clock() # Get current time (in milliseconds)
# may use
# from ctypes import windll
# clak2 = windll.kernel32.GetTickCount()
# or
# clak2 = windll.winmm.timeGetTime()
# as well,
# but using the time module makes the program platform-independent
# so I chose the latter one. the data processing is different, of course.
if flag and not tmstr:
el=clak2-clak1 # el stands for elapsed time
hr=int(el/3600)
el%=3600
minit=int(el/60)
el%=60
sec=int(el)
# el may suffered a lot from float processing so I recalculated
# i don't know if it's necessary to do that
# is there anybody who can help me?
millisec=((clak2-clak1)%1)*1000
print "%ihr %i' %i'' %f" % (hr, minit, sec, millisec)
flag = False
else:
clak1, flag=clak2, True
> 我来回应
这个小组的成员也喜欢去 · · · · · ·

- Django (1351)

- Vim (3286)

- Google App Engine (1427)

- Linux (4227)

- ubuntu (4541)

- Ruby (1154)
最新话题:
大家是为啥选择python? (Lydia)
可爱的Python (码工)
请大家谈谈对各种python web框架的感受和优缺点! (米奇·猴)
thread 模块请教 (御风)
who use the memagent (基地组织土匪头)