当前位置: 移动技术网 > IT编程>脚本编程>Python > Python计算程序运行时间的方法

Python计算程序运行时间的方法

2019年03月24日  | 移动技术网IT编程  | 我要评论

like团怎么样,青蛙军曹,百科知识网

本文实例讲述了python计算程序运行时间的方法。分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:

import time

def start_sleep():
    time.sleep(3)

if __name__ == '__main__':
    #the start time
    start = time.clock()

    #a program which will run for 3 seconds
    start_sleep()

    #the end time
    end = time.clock()

    print("the function run time is : %.03f seconds" %(end-start))

    # end

希望本文所述对大家的python程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网