伙计们,我刚刚开始编码,正在尝试一些新事物,但是在查看了所有代码行之后,我仍然遇到了所有错误。
代码:
import time
"""
This is a prastise session
"""
list=[]
for i in range(10):
list.append(datetime.datetime.now())
time.sleep(2)
错误:
Traceback (most recent call last):
File "importtime.py", line 11, in <module>
list.append(datetime.datetime.now())
NameError: name 'datetime' is not defined
有人可以帮忙吗? 谢谢
答案 0 :(得分:0)
您需要导入日期时间:
import datetime
import time
"""
This is a prastise session
"""
list=[]
for i in range(10):
list.append(datetime.datetime.now())
time.sleep(2)