Python: Record the running time of the program (record the time difference between two points in time)

It's very simple, just use the time function in time. This function returns the current time by subtracting the starting time from the ending time.

from time import time

start = time()
# 中间你可以编写其它代码
end = time()

print("程序运行时间为:" + str(end-start) + "秒")

That's it for today's course. Although it is very short, I hope you can learn the essence, bye!

Guess you like

Origin blog.csdn.net/wangzirui32/article/details/113894680