想看程序运行时间,而python中又没有类似matlab的tic,toc函数,只能自己写程序实现该功能啦~
主要是想就是,程序开始记下当前时间,程序结束记下当前时间,作差即为程序运行时间
from datetime import datetime
tic = datetime.now()
...
<程序段>
...
toc = datetime.now()
print('Elapsed time: %f seconds' % (toc-tic).total_seconds())
本文介绍了一种在Python中测量程序运行时间的方法。通过记录程序开始和结束的时间戳,并计算两者之间的差值来获取程序的运行时间。
518

被折叠的 条评论
为什么被折叠?



