Python Time.sleep()错误

Python Time.sleep()错误,python,Python,所以时间不起作用了。我使用的是Python3.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 =

所以时间不起作用了。我使用的是Python3.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()

将其更改为以下内容:

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()

在导入语句中,您已经导入了日历,您还应该导入时间。睡眠是时间包中的一部分。 导入日历 导入时间

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()

您可能希望导入时间,就像当前导入时间一样。睡眠(1)实际上没有定义,只需将导入添加到代码顶部,这将解决问题。

您需要导入时间