Python 睡眠时间错误

Python 睡眠时间错误,python,Python,此代码中有一个错误 time.sleep(5) print ("Loading Successfull")` 当我运行这段代码时,会弹出一个错误,上面写着: NameError: name 'time' is not defined 我想我不需要定义时间 我最近使用过这个命令,它从来没有说它是第一次发生的TimeError print ("-----------------Welcome to Digits counter-----------------")#Welcomes the us

此代码中有一个错误

time.sleep(5)
print ("Loading Successfull")`
当我运行这段代码时,会弹出一个错误,上面写着:

NameError: name 'time' is not defined
我想我不需要定义时间

我最近使用过这个命令,它从来没有说它是第一次发生的
TimeError

print ("-----------------Welcome to Digits counter-----------------")#Welcomes the user
print ("")
print ("Loading...")
time.sleep (3)
print("Load Sucessfull")

您需要先导入
时间
模块

import time

time.sleep(5)
或者不导入完整的
时间
模块,只需从
时间
导入
睡眠

from time import sleep
sleep(5)

其余的代码保持不变。

导入模块
导入时间
像这样吗<代码>导入时间
time.sleep(3)
现在,只需“导入时间”就可以看到完整的“数字计数器”应用程序启动并运行;)也许你会想重新考虑一个“加载”阶段,它除了睡觉什么都不做。可能是重复的