注意
注意不足1秒的时间要
四舍五入到秒,我使用的方法是round()时间输出注意
高位补零,即%02d
代码如下
def time():
content = map(int, raw_input().split(' '))
CLK_TCK = 100
if content[0] >= content[1]:
return
allSecond = round(float(content[1]- content[0]) / CLK_TCK)
time = [0, 0, 0]
i = 2
while allSecond > 60:
time[i] = allSecond % 60
allSecond = allSecond / 60
i = i - 1
time[i] = allSecond % 60
print "%02d:%02d:%02d"% (time[0], time[1], time[2])
if __name__ == '__main__':
time()
测试结果


本文介绍了如何在Python中测量程序运行时间,强调了不足1秒时间的处理方法,并提供了具体的代码示例及测试结果。
284





