问题
I'm getting the following error:
The error:"Traceback (most recent call last):
File "C:\Users\Jamie\Desktop\Python\ATM.py", line 8, in <module>
time.sleep(2)
NameError: name 'time' is not defined"
here is my code:
http://pastebin.com/q2v7sdbz
Any ideas towards what may be throwing this?
Best,
Jamie
回答1:
the sleep
function comes from the python time
module so you to import
before you call any of it's methods
just put
import time
before you use any time stuff. It's normal to just put all of your imports at the top of your code.
see here for more info on import
ing:
https://docs.python.org/3/reference/import.html
回答2:
You need to import the time
module. Just write import time
at the top of your file on its own line to import it.
来源:https://stackoverflow.com/questions/23616507/python-3-3-3-time-sleep-error