python中类似matlab的tic,toc程序自我实现

想看程序运行时间,而python中又没有类似matlab的tic,toc函数,只能自己写程序实现该功能啦~

主要是想就是,程序开始记下当前时间,程序结束记下当前时间,作差即为程序运行时间


from datetime import datetime
tic = datetime.now()

...

<程序段>

...
toc = datetime.now()
print('Elapsed time: %f seconds' % (toc-tic).total_seconds())

猜你喜欢

转载自blog.csdn.net/u010199776/article/details/69941965