import time
def calculate_time(total_time):
'''
total_time: total seconds
'''
spend_seconds = total_time % 60
totalminutes = total_time // 60
spend_minutes = totalminutes % 60
spend_hours = totalminutes // 60
return spend_hours, spend_minutes, spend_seconds
def main():
start_time = time.time()
‘’‘
相关程序
’‘’
end_time = time.time()
total_time = end_time - start_time
spend_hours, spend_minutes, spend_seconds = calculate_time(total_time)
print 'Total running time of the example: %.2f seconds ( %i hours %i minutes %.2f seconds )' \
% (total_time, spend_hours, spend_minutes, spend_seconds)
main()
python计算程序运行时间
最新推荐文章于 2023-12-12 09:15:37 发布