时间。睡觉()E

2024-04-19 09:33:56 发布

您现在位置: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 = 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()

Tags: nonamecreatinginputagetime时间sleep
3条回答

您可能希望import time,因为目前{}没有实际定义,只需将导入添加到代码的顶部,这样就可以修复它。在

改为:

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

相关问题 更多 >