import time
start = time.perf_counter()
# 在此导入time库,并在开头设置开始时间
################################
end = time.perf_counter()
# 在程序运行结束的位置添加结束时间
################################
print("运行耗时", end-start)
# 再将其进行打印,即可显示出程序完成的运行耗时
使用Python3.8,这样使用time库
import time
start = time.perf_counter()
# 在此导入time库,并在开头设置开始时间
################################
end = time.perf_counter()
# 在程序运行结束的位置添加结束时间
################################
print("运行耗时", end-start)
# 再将其进行打印,即可显示出程序完成的运行耗时
使用Python3.8,这样使用time库