使用python来统计程序运行时间 在python中,time是用来统计程序运行时间的包,首先先导入time包。 from time import time 然后,先在需要计算运行时间的代码片段前面,使用变量start储存下当前时间。 start = time() 再在运行完的程序片段最后,统计当前时间,和start变量两者作差即可。 from time import time start = time() #中间这里是 #需要统计运行时间的代码片段 print