所以time.sleep不起作用。我在python 3.4.3上,我的计算机上没有这个问题3.6。
这是我的代码:
import calendar
def ProfileCreation():
Name = input("Name: ")
print("LOADING...")
time.sleep(1)
Age = input("Age: ")
print("LOADING...")
time.sleep(1)
ProfileAns = input("This matches no profiles. Create profile? ")
if ProfileAns.lower == 'yes':
print("Creating profile...")
elif ProfileAns.lower == 'no':
print("Creating profile anyway...")
else:
print("yes or no answer.")
ProfileCreation()
ProfileCreation()
答案 0 :(得分:2)
您可能希望import time
目前time.sleep(1)
尚未实际定义,只需将导入添加到代码顶部即可解决此问题。
答案 1 :(得分:0)
将其更改为以下内容:
import calendar
import time
def ProfileCreation():
Name = input("Name: ")
print("LOADING...")
time.sleep(1)
Age = input("Age: ")
print("LOADING...")
time.sleep(1)
ProfileAns = input("This matches no profiles. Create profile? ")
if ProfileAns.lower == 'yes':
print("Creating profile...")
elif ProfileAns.lower == 'no':
print("Creating profile anyway...")
else:
print("yes or no answer.")
ProfileCreation()
ProfileCreation()
答案 2 :(得分:0)
在导入语句中,您已导入日历,您也应导入时间。睡觉是在时间包内。 导入日历 进口时间
def ProfileCreation():
Name = input("Name: ")
print("LOADING...")
time.sleep(1)
Age = input("Age: ")
print("LOADING...")
time.sleep(1)
ProfileAns = input("This matches no profiles. Create profile? ")
if ProfileAns.lower == 'yes':
print("Creating profile...")
elif ProfileAns.lower == 'no':
print("Creating profile anyway...")
else:
print("yes or no answer.")
ProfileCreation()
ProfileCreation()