如何使用导入时间库在Python中实现Clock()方法?
import time
print(chr(27) + "[2J") # Somehow this clears the console??
print("*************************")
# Get the current processor
# time in seconds
program_time = time.clock()
# print the current
# processor time
print("Current processor time (in seconds):", program_time)
时间库具有一个有效的方法,称为clock()。但是当我运行代码时,我会收到一个错误:
attributeError:模块'time'没有属性'时钟'
import time
print(chr(27) + "[2J") # Somehow this clears the console??
print("*************************")
# Get the current processor
# time in seconds
program_time = time.clock()
# print the current
# processor time
print("Current processor time (in seconds):", program_time)
The time library has a valid method called clock(). But when I run the code I get an error:
AttributeError: module 'time' has no attribute 'clock'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 python 3.8 的新事物
time.Clock
未始终如一地实现,新的API旨在涵盖其各种用途。From What’s New In Python 3.8
time.clock
was not implemented consistently cross-platform and the new API is meant to cover its various uses.